var date = new Date();
console.log(date.toLocaleDateString());
console.log(date.toDateString());
console.log(date.toLocaleString());
console.log(date.toUTCString());
console.log(date.toISOString());
var dateString = new Date().toDateString();
console.log(dateString, '\n');
var dateString = new Date().toLocaleDateString();
console.log(dateString, '\n');
var dateString = new Date().toGMTString();
console.log(dateString, '\n');
5条答案
按热度按时间ncgqoxb01#
字符串
从这里选择您的方法:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
mcdcgff02#
你可以做下面这些陈述
字符串
ctehm74n3#
从上面的答案中,我们也可以用一行来做。如下所示,
字符串
o4hqfura4#
您可以将从
Date.now()
获得的值传递给new Date()
,这将以可读格式给予时间。举例来说:
字符串
xdyibdwo5#
new Date();
个字符