更改时区格式

发布于 2025-02-13 04:50:46 字数 352 浏览 1 评论 0 原文

使用TolocalString()将我的日期时区置于我的日期时区之后,

new Date(dateParam).toLocaleString('en-US', { timeZone: "Australia/Sydney" })

我得到了此字符串 5/25/2022,8:44:46 pm ,我如何从这种格式转换为默认 new Date( ) fromat 星期二7月5日2022 23:22:37 GMT+0300 ,能够使用日期方法(示例:: todateString(),getluceAr())?

after chaning my date timezone using toLocalString()

new Date(dateParam).toLocaleString('en-US', { timeZone: "Australia/Sydney" })

i've got this string 5/25/2022, 8:44:46 PM, how can i transform from this format to default new Date() fromat Tue Jul 05 2022 23:22:37 GMT+0300, to be able to use Date methods(example: toDateString(), getFullYear())?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人爱我别走 2025-02-20 04:50:46

在下面的示例中添加两个参数数据和及时的参数

console.log(new Intl.DateTimeFormat('en-GB', { dateStyle: 'full', timeStyle: 'long' }).format(date));
// Expected output "Sunday, 20 December 2020 at 14:23:16 GMT+11"

add to your solution two parameters dataStyle and timeStyle like in the example below

console.log(new Intl.DateTimeFormat('en-GB', { dateStyle: 'full', timeStyle: 'long' }).format(date));
// Expected output "Sunday, 20 December 2020 at 14:23:16 GMT+11"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文