xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

moment.js & day.js All In One

moment.js & day.js All In One

js Date

Date.now();
// 1618902426644

const date = new Date();

date.getFullYear();
// 2021
date.getMonth() + 1;
// 4
date.getDate();
// 20
date.getDay();
// 2

date.toLocaleString();
// "4/20/2021, 3:06:58 PM"
date.toLocaleDateString();
// "4/20/2021"
date.toLocaleTimeString();
// "3:06:58 PM"

moment.js

https://github.com/moment/moment/

https://momentjs.com/docs/#/parsing/string-format/

913
45.6k
6.9k


moment("4/12").format('YYYY-MM-DD');
// "2001-04-12"

day.js

https://day.js.org/

https://github.com/iamkun/dayjs

296
34.6k
1.6k


dayjs("4/12").format('YYYY-MM-DD');
// "2001-04-12"

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-04-19 12:00  xgqfrms  阅读(61)  评论(0编辑  收藏  举报