简体   繁体   English

我需要使用 moment.js 根据本地时区转换 UTC 日期和时间,如何将日期从 UTC 转换为 html 中的时区

[英]I need to convert UTC date and time based on the local timezone using moment.js, how to convert date from UTC to timezone in html

The code below is displaying date in UTC format not in local timezone.下面的代码以 UTC 格式显示日期,而不是本地时区。

<mat-cell *matCellDef="let element; let i=index" class="table-width__26">
  {{moment(element.CREATED_DATE).format('MM/DD/YYYY')}} {{'at'}}
  {{ getTime(element.CREATED_DATE,timezone)}} 
  {{ moment.tz([2012,0],timezone).format('z').substr(0, 1) + moment.tz([2012,0],timezone).format('z').substr(2)}}
</mat-cell>

If you can find your timezone name you can use at below:如果你能找到你的时区名称,你可以在下面使用:

moment(1369266934311).tz(' Melikgazi/Kayseri').format('YYYY-MM-DD HH:mm')

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

相关问题 如何使用moment.js和moment-timezone.js将特定时区(非本地)的给定日期/时间转换为UTC - How to convert a given date/time for a specific timezone (not local) to UTC using moment.js and moment-timezone.js 使用 moment 基于时区将字符串日期和时间转换为 UTC - convert string date and time to utc based on timezone using moment Moment.js:将UTC日期从数据库转换为本地时间 - Moment.js: Convert UTC date from database into local time 如何在本地时区中将UTC时间字符串转换为正确的moment.js对象? - How can I convert a UTC time string to the correct moment.js object in my local timezone? 在javascript(moment.js)中将UTC日期转换为当地时间 - convert UTC date to local time in javascript (moment.js) moment.js和moment.timezone.js-我如何知道客户端时区以本地tz显示UTC日期? - moment.js, and moment.timezone.js - how do i know the client timezone to display UTC date in local tz? 使用 moment.js 将日期转换为 UTC - Convert date to UTC using moment.js moment-timezones.js,如何将特殊时区中的日期转换为utc,而不考虑我的本地时区? - moment-timezones.js, how to convert date in spesific timezone to utc, disregarding my local timezone? 使用 Moment.js 将 UTC 日期和时间转换为本地日期和时间 - Convert UTC Date and Time to local Date and Time using Moment.js UTC日期转换为本地时区 - UTC date convert to local timezone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM