📜 ⬆️ ⬇️

Moment.js: easy work with dates


Moment.js is an excellent library for working with dates in JavaScript. Examples under the cut.

var now = moment(); moment.lang('ru'); console.log(now.format('dddd, MMMM DD YYYY, h:mm:ss')); // ,  15 2011, 3:31:03 


 var halloween = moment([2011, 9, 31]); // October 31st moment.lang('ru'); console.log(halloween.fromNow()); // 16   


 var now = moment().add('days', 9); moment.lang('ru'); console.log(now.format('dddd, MMMM DD YYYY')); // ,  24 2011 

')
 var now = moment(); moment.lang('ru'); console.log(now.format('LLLL')); // , 15  2011 15:27 


Well, actually links:
Offsite | Documentation | github

PS In my opinion the most adequate to work with dates. It remains only to finish the normal support of the Russian language.

Source: https://habr.com/ru/post/132654/


All Articles