I am having similar requirement as this: Convert time in HH:MM:SS format to seconds only?
but in javascript. I have seen many examples of converting seconds into different formats but not HH:MM:SS into seconds. Any help would be appreciated.
I am having similar requirement as this: Convert time in HH:MM:SS format to seconds only?
but in javascript. I have seen many examples of converting seconds into different formats but not HH:MM:SS into seconds. Any help would be appreciated.
Output: 1499755980000 (in millisecond) ( 1499755980000/1000) (in second)
Note : this output calculate diff from 1970-01-01 12:0:0 to now and we need to implement the moment.js
You can do this dynamically - in case you encounter not only: HH:mm:ss, but also, mm:ss, or even ss alone.
This function handels "HH:MM:SS" as well as "MM:SS" or "SS".
Convert
hh:mm:ss
string to seconds in one line. Also allowedh:m:s
format andmm:ss
,m:s
etcSince the getTime function of the Date object gets the milliseconds since 1970/01/01, we can do this: