获取UTC日期按日期和时区名称
我需要一个功能来获得UTC日期时间。我仅通过日期,时间和时区名称。我需要获取UTC时间和日期。谢谢你
:
const utcDate = getUTCDateTime("2022-05-10","18:00" "America/Hermosillo");
// OutPut should be like this ==>> 2022-05-11T01:00:00.527Z
function getUTCDateTime(date,time, timeZoneName){
//Logic
return utcDate;
}
I need a function to get UTC date-time. I passed only the date, time and time zone name only. I need to get the UTC time and date. Thank You
Ex:
const utcDate = getUTCDateTime("2022-05-10","18:00" "America/Hermosillo");
// OutPut should be like this ==>> 2022-05-11T01:00:00.527Z
function getUTCDateTime(date,time, timeZoneName){
//Logic
return utcDate;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将使用一个库,例如 day.js 为此目的。您可以在时区中的日期和时间分析,转换为UTC,然后以所需格式显示。
I would use a library like Day.js for this purpose. You can parse in the date and time in a timezone, convert to UTC, then display in the desired format.