首页 > 解决方案 > 如何使用 .toLocaleDateString() 以 2020 年 10 月 29 日等格式显示日期以供 en-us 使用?

问题描述

我不确定如何重新排列从 .toLocaleDateString() 显示的日期顺序。

thisDate.toLocaleDateString('en-us', { year: 'numeric', day: '2-digit', month: 'short', hour: 'numeric', minute: 'numeric', hour12: true });

我尝试重新排列期权订单,但似乎没有任何东西可以重新排列订单,所以无论我希望它显示 2020 年 10 月 29 日时做什么,我都会得到 2020 年 10 月 29 日。

标签: javascriptdateformat

解决方案


尝试使用en-GB语言环境

const date = new Date().toLocaleDateString('en-GB', { year: 'numeric', day: '2-digit', month: 'short' });

console.log(date)


推荐阅读