简体   繁体   English

如何将 JS 日期时间转换为本地 MySQL 日期时间?

[英]How to convert JS date time to Local MySQL datetime?

Best result i get is this, its simplest code i found here and save to MySQL on correct format.我得到的最好结果是这个,我在这里找到了最简单的代码,并以正确的格式保存到 MySQL。 but i need to get GMT+7 datetime, how to add additional 7 Hours to this script?但我需要获取 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>`

Result:结果:

2018-11-23 11:14:38 
Current Date is displayed above...

If you just need to add 7 hours here is an example:如果您只需要添加 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM