+ 2
Time in Javascript?
I dont know how to get the current time as a value. Can someone help or maybe reference a lesson please? I had no luck in q&a forums...
3 Antworten
+ 8
You can do it like this:
var d = new Date();
d.getHours() //get hour in 24 hr format
d.getMinutes() //get minutes
Here are some websites that you can visit:
(1) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
(2) https://www.w3schools.com/js/js_dates.asp
(3) https://www.tutorialspoint.com/javascript/javascript_date_object.htm
+ 4
https://www.w3schools.com/js/js_date_methods.asp
+ 3
You can get the current time by creating instance of Date() object you can access hours, seconds, minutes as explained in the sololearn js course.