更新时间:2023-01-31 16:09:53
The Date#toDateString
method would result always returns in that particular format.
因此,您需要使用其他可用的方法来生成,或者可以使用几种方法来删除,
So either you need to generate using other methods available or you can remove using several ways,
String#split 代码>
, Array#slice
和 Array#join
var mydate = new Date('29 Feb 2020');
// split based on whitespace, then get except the first element
// and then join again
alert(mydate.toDateString().split(' ').slice(1).join(' '));
String#replace 代码>
var mydate = new Date('29 Feb 2020');
// replace first nonspace combination along with whitespace
alert(mydate.toDateString().replace(/^\S+\s/,''));
String#indexOf 代码>
和 String#substr
var mydate = new Date('29 Feb 2020');
// get index of first whitespace
var str = mydate.toDateString();
// get substring
alert(str.substr(str.indexOf(' ') + 1));