[英]Get long locale date format without momentjs
I have been migrating from moment.js to date-fns and was stuck at a point where couldn't find an alternative for我一直在从 moment.js 迁移到 date-fns 并且陷入了找不到替代方案的地步
moment.localeData().longDateFormat("LL");
For more information :想要查询更多的信息 :
localeData = moment.localeData()
localeData.longDateFormat()
returns返回
{
LT : 'HH:mm',
LTS : 'HH:mm:ss',
L : 'DD/MM/YYYY',
LL : 'D MMMM YYYY',
LLL : 'D MMMM YYYY HH:mm',
LLLL : 'dddd, D MMMM YYYY HH:mm'
}
In general , is there any alternative for this function in date-fns or vanilla js ?一般来说,在date-fns或 vanilla js 中是否有此功能的替代方案?
After digging for a while , The PPP format within date-fns , can be used .挖了一会,date-fns里面的PPP格式,就可以用了。 Other solution for it can be to use Intl.DateTimeFormat with the suitable parameters as mentioned in the docs .其他解决方案可以是将Intl.DateTimeFormat与文档中提到的合适参数一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.