Wed Jan 01 1000 00:00:00 GMT+0800 (GMT+08:00)
时间: 2024-03-19 17:37:15 浏览: 93
python 带时区的日期格式化操作
在JavaScript中,可以使用Date对象将日期格式转换为所需的格式。以下是将"Wed Jan 01 1000 00:00:00 GMT+0800 (GMT+08:00)"转换为"yyyy-mm-dd hh:mm:ss"格式的示例代码:
```javascript
var dateStr = "Wed Jan 01 1000 00:00:00 GMT+0800 (GMT+08:00)";
var date = new Date(dateStr);
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
var hours = ("0" + date.getHours()).slice(-2);
var minutes = ("0" + date.getMinutes()).slice(-2);
var seconds = ("0" + date.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
console.log(formattedDate); // 输出:1000-01-01 00:00:00
```
阅读全文