简体   繁体   English

如何在 JavaScript 的页面上显示当前时区、日期和时间?

[英]How can I show the current timezone, date, and time on the page in JavaScript?

I need to show the current timezone, date and time on the web page in the same format as shown below every second with JavaScript.我需要在 web 页面上以与 JavaScript 每秒显示的相同格式显示当前时区、日期和时间。

Ex: (GMT-05:00) 8/16/2022 01:30:00 PM例如:(GMT-05:00) 2022 年 8 月 16 日下午 1:30:00

Thanks in advance!提前致谢!

You can create a new date object using var date = Date() then you can parse out every details such as time, date and timezone from that object using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date您可以使用 var date = Date() 创建一个新的日期 object 然后您可以使用Z5E056C500A1C4B6A7110B50D807BADEen-US/zweb.org/从该 object 解析出所有详细信息,例如时间、日期和时区。 JavaScript/参考/Global_Objects/日期

this website contains all of the different things you can parse out该网站包含您可以解析的所有不同内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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