my datetime format is given below.
var datetime =Wed Apr 8 15:05:00 UTC+0530 2015;
I only want to get the time 15.05
The moment(). hour() Method is used to get the hours from the current time or to set the hours. moment(). hours();
You can directly call function momentInstance. valueOf(), it will return numeric value of time similar to date. getTime() in native java script.
We can remove the time portion from a date with the startOf method. We pass in a date with the hour and minutes set into the moment function. Then we call startOf with the 'day' argument to get return a moment object with the time set to midnight of the same date.
Try: moment({ // Options here }). format('HHmm') . That should give you the time in a 24 hour format.
Use format()
and specify the desired token.
moment().format('HH.mm')
.
Docs for tokens can be found here
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