js 将字符串格式化yyyy-mm-dd hh:mm:ss
时间: 2024-05-18 15:11:13 浏览: 103
要将字符串格式化为"yyyy-MM-dd HH:mm:ss"的格式,可以使用JavaScript中的Date对象和相关方法来实现。下面是一个示例代码:
```javascript
var dateString = "2015-07-16 17:07:21";
var dateParts = dateString.split(" ");
var date = dateParts<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Java 时间格式由yyyy-MM-dd HH:mm:ss 转换为 yyyy-MM-dd‘T‘HH:mm:ss](https://blog.csdn.net/weixin_44181419/article/details/128562911)[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* *3* [关于java:如何将字符串转换为yyyy-MM-dd HH:MM:ss格式的日期](https://blog.csdn.net/weixin_30083369/article/details/114714904)[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 ]
阅读全文