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://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, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14676251.html
未经授权禁止转载,违者必究!