定义和用法
tolocalestring() 方法可根据本地时间把 date 对象转换为字符串,并返回结果。
语法
dateObject.toLocaleString()
返回值
dateObject 的字符串表示,以本地时间区表示,并根据本地规则格式化。
实例
例子 1
在本例中,我们将根据本地时间把今天的日期转换为字符串:
输出:
2017/11/8 下午2:06:15
例子 2
在本例中,我们将根据本地时间把具体的日期转换为字符串:
立即学习“Java免费学习笔记(深入)”;
输出:
1983/7/21 上午1:15:00
如何使用 toLocaleString() 来根据本地时间把今天的日期转换为字符串。
结果:
2017/11/8 下午2:07:26











