美文网首页
当前时间返回字符串

当前时间返回字符串

作者: easy_mark | 来源:发表于2018-04-13 15:06 被阅读0次

语法: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

相关文章

网友评论

      本文标题:当前时间返回字符串

      本文链接:https://www.haomeiwen.com/subject/qtwckftx.html