Date formatting in js

There is a module called moment.js
https://momentjs.com/
Lightweight date formatting module: day2.js

moment(val).isValid    //判断值是否存在
moment(val).format('MMMM Do YYYY, h:mm:ss a'); // March 5th 2020, 10:17:43 pm
moment(val).format('dddd');                    // Thursday
moment(val).format("MMM Do YY");               // Mar 5th 20
moment(val).format('YYYY [escaped] YYYY'); // 2020 escaped 2020
moment(val).format();        // 2020-03-05T22:17:43+08:00
                                           

Guess you like

Origin blog.csdn.net/qq_42535651/article/details/104685827