将 utc 日期时间转换为 Angular 本地时间

问题描述 投票:0回答:1

我得到这个日期时间格式

2023 年 11 月 18 日星期六 22:30:00 GMT+0530(印度标准时间)

this.selectedDate = info.date;

我想将此日期时间转换为本地日期时间对象,但格式将相同

javascript angular date time pipe
1个回答
0
投票

您创建一个

Date
对象,然后调用
toString()

let date = new Date("Sat Nov 18 2023 22:30:00 GMT+0530 (India Standard Time)");
console.log(date.toString());

由于我位于东欧,它将日期转换为我的时区并相应地显示:

© www.soinside.com 2019 - 2024. All rights reserved.