Hello.
I use the Moment.js
library. I am trying to bring the difference in time in the right format. And now I can not understand how to combine one with another. At the moment I have:
moment.lang ('RU');
// Result Will: 2016-03-30 23:59:57
$ ('. Block'). HTML (Moment ('2016-03-30 23:59:57'). Format ('YYYY-MM-DD HH: MM: SS'));
// Result will be: a month ago
$ ('. Block'). HTML (Moment ('2016-03-30 23:59:57'). Fromow ());
Trying to bring something like this 0000-00-27 06:58:52
– here is the amount of time how much passed, from the date of the date specified in .moment (…). Simply put, it is necessary to show in such a format: Yyyy-Mm-DD HH: mm: SS
time difference.
What needs to be done to implement the dates output in the desired format?
Answer 1, Authority 100%
var moment = require ('moment');
moment.locale ('RU');
var now = moment ();
VAR EVENT = MOMENT ('2016-03-30 23:59:57');
Console.log ('Today:' + Now.Format ('Yyyy-Mm-DD HH: MM: SS'));
Console.log ('Event Date:' + Event.Format ('Yyyy-Mm-DD HH: MM: SS'));
Console.log ('Event happened' + event.fromnow ());
Console.log ('Time Difference:' + Now.Subtract (Event.ToObject ()). Format ('Yyyy-Mm-DD HH: MM: SS'));