[英]How to convert JS date time to Local MySQL datetime?
我得到的最好結果是這個,我在這里找到了最簡單的代碼,並以正確的格式保存到 MySQL。 但我需要獲取 GMT+7 日期時間,如何在此腳本中添加額外的 7 小時?
<html>
<head>
<title>Web Page Design</title>
<script>
document.writeln(new Date().toISOString().slice(0, 19).replace('T', ' '));
</script>
</head>
<body><br>Current Date is displayed above...</body></html>`
結果:
2018-11-23 11:14:38
Current Date is displayed above...
如果您只需要添加 7 小時,這里是一個示例:
<html> <head> <title>Web Page Design</title> <script> var now = new Date(); now.setHours(now.getHours() + 7); document.writeln(now.toISOString().slice(0, 19).replace('T', ' ')); </script> </head> <body><br>Current Date is displayed above...</body> </html>`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.