JavaScript date toLocaleString()方法根据本地时间格式,把 Date 对象转换为字符串。
toLocaleString() - 语法
Date.toLocaleString ()
toLocaleString() - 返回值
以字符串格式返回格式化日期。
toLocaleString() - 示例
var dt=new Date(1993, 6, 28, 14, 39, 7); console.log( "Formated Date : " + dt.toLocaleString() );
运行上面代码输出
Formated Date : 7/28/1993, 2:39:07 PM