moment.js common formatting process various time methods

moment.js common formatting methods to deal with various time.jpg

Moment.js is an easy-to-use lightweight JavaScript date processing library that provides functions such as date formatting and date parsing. It supports running in both browser and NodeJS environments. This type of library can convert a given arbitrary date into a variety of different formats, has powerful date calculation functions, and also has built-in functions that can display various date forms. In addition, it also supports multiple languages, and you can add a new language pack arbitrarily.

Format time format:

moment().format();                   // "2014-09-08T08:02:17-05:00" (ISO 8601,无小数秒钟)
moment().format('YYYY-MM-DD HH:mm:ss');                 //  "2014-09-08 08:17:12
moment().format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Sunday, February 14th 2010, 3:25:50 pm"
moment().format("ddd, hA");              // "Sun, 3PM"

For more formatting configuration parameters, please see the appendix at the bottom

calendar() 

Calendar time displays the time relative to the given referenceTime (default is now), but with m

Guess you like

Origin blog.csdn.net/mo3408/article/details/131793171