JavaScript Date 对象转换为中文年月日时分秒
可以使用 JavaScript 的 toLocaleString() 方法将 Date 对象转换为中文表示的年月日时分秒。
以下是一个示例:
const date = new Date();
const options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
const chineseDate = date.toLocaleString('zh-CN', options);
console.log(chineseDate);
输出结果类似于:2022年1月1日 下午12:34:56
原文地址: https://www.cveoy.top/t/topic/o57r 著作权归作者所有。请勿转载和采集!