当前时间返回字符串

2018-04-13  本文已影响0人  easy_mark

语法:dateObject.toLocaleString();

例子 1

在本例中,我们将根据本地时间把今天的日期转换为字符串:

var d = new Date()

document.write(d.toLocaleString())

输出:

2018/4/13 下午3:01:11

例子 2

在本例中,我们将根据本地时间把具体的日期转换为字符串:

var born = new Date("July 21, 1983 01:15:00")

document.write(born.toLocaleString())

输出:

1983/7/21 上午1:15:00

上一篇 下一篇

猜你喜欢

热点阅读