If you are using a date and time field and would like to output the difference between the two dates in days, hours and minutes, use the following template: var m1 = moment('{admission}', 'DD-MM-YYYY HH:mm'); var m2 = moment('{discharge}', 'DD-MM-YYYY HH:mm'); var m3 = m2. diff(m1,'minutes'); var m4 = m2.
Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.
Return Value: This function returns the date in milliseconds.
I'm using moment.js and want to calculate the difference between two timestamp,format them afterwards and display them in a div.
var diffTime = moment(1390310146.791877).diff( 1390309386.271075);
This gives me 760 seconds, but I want to format it like this:
(days, hrs, mins, secs) and only show days, hours and seconds if they are higher than 0.
How do I achieve that ?
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