如何将字符串“Mon Jun 01 2015 00:00:00 GMT+0100 (IST)”转换为 2015-03-25,这是 Angular 和 javascript 的新手。有没有什么函数可以进行这种转换?
最佳答案
好的,这对我有用
2015 年 6 月 1 日星期一 00:00:00 GMT+0100 (IST)
var date = new Date('Mon Jun 01 2015 00:00:00 GMT+0100 (IST)');
console.log(date);
var formatedDate = (date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate());
console.log('Formated date' + formatedDate);
关于javascript - 将字符串日期格式 "Mon Jun 01 2015 00:00:00 GMT+0100 (IST)"更改为 "YYYY-MM-DD",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30911551/