如何从Date字符串中删除时间

时间:2015-02-14 13:37:12

标签: javascript

var x = new Date();
myVar = x.toString();
document.write(myVar);
// Sat Feb 14 2015 14:20:58 GMT+0100 (CET)

我想删除时间<<<< 14:20:58 GMT + 0100(CET)>>

1 个答案:

答案 0 :(得分:9)

尝试......

var x = new Date()
var myVar = x.toDateString(); 

这只会提供日期......

文档:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString