我需要在应用程序中以某种格式显示日期。我有输入的' 2009 -04-01‘作为字符串,我希望这个格式2009年4月1日使用Javascript。
发布于 2019-05-31 06:53:16
创建Date对象:
const date = new Date('2009-04-01');使用toLocaleString格式化Date
date.toLocaleString('en-us', { month: 'long', day: 'numeric', year: 'numeric' });发布于 2019-05-31 06:49:06
只需创建一个新的Date对象,然后使用它来格式化输出:
d = new Date("2009-04-01")https://stackoverflow.com/questions/56386522
复制相似问题