js yyyy-mm-dd hh:mm:ss转为date
时间: 2024-05-16 19:19:28 浏览: 203
要将JavaScript中的yyyy-mm-dd hh:mm:ss格式转换为日期对象,可以使用以下方法之一:
1. 使用new Date()构造函数和字符串拼接的方式:
```
var dateString = 'yyyy-mm-dd hh:mm:ss';
var dateParts = dateString.split(' ');
var date = new Date(dateParts + 'T' + dateParts<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Js各种时间转换问题(YYYY-MM-DD 时间戳 中国标准时间)](https://blog.csdn.net/qq_41867900/article/details/126610559)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [js将日期格式转换为YYYY-MM-DD HH:MM:SS](https://download.csdn.net/download/weixin_38690545/14671498)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文