So the question is described in title. I need to get current second of the day using JavaScript.
JavaScript Date getSeconds() getSeconds() returns the seconds (0 to 59) of a date.
getSeconds() The getSeconds() method returns the seconds in the specified date according to local time.
var dt = new Date(); dt. setTime(dt. getTime() + (24 * 60 * 60 * 1000));
You add up the bits:
var dt = new Date();
var secs = dt.getSeconds() + (60 * dt.getMinutes()) + (60 * 60 * dt.getHours());
or if you prefer
var dt = new Date();
var secs = dt.getSeconds() + (60 * (dt.getMinutes() + (60 * dt.getHours())));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With