Questions tagged [moment-timezone]

Moment-timezone is an add-on for Moment.js that provides IANA time zone support. Use this tag for issues with moment-timezone, but also tag it with [moment]. NOTE: As of September 2020, the Moment team recommends you chose a different library for new projects. See the Project Status section of the Moment docs. On StackOverflow, please refrain from recommending Moment as a solution unless Moment is specifically asked for in the question.

Moment-timezone is an add-on for Moment.js that provides IANA time zone support.


Important:

As of September 2020, the Moment team recommends you choose a different library than Moment for new projects. Please read https://momentjs.com/docs/#/-project-status/

On StackOverflow, please refrain from recommending Moment as a solution unless Moment is specifically asked for in the question.

401 questions
1
vote
1 answer

Validating time zone in a Joi schema

I want to accept a request that sends several query parameters with it and I am validating it using Joi library in Nodejs/Express but can't figure out how to validate time zone values(which is one of the query parameters? function…
1
vote
4 answers

How add and subtract days using Moment JS for the given timestamp value?

I have unixtimestamp value 1628312400000 // 7th Aug 2021 var selectedDate = moment(1628312400000); let formattedDate = moment.tz(day, "America/Chicago").format('DD-MM-YYYY')+ " " +"00:00:00"; //07-08-2021 00:00:00 Now, I want the previous day and…
Vadivel A
  • 51
  • 7
1
vote
1 answer

How to get next occurance of an rrule for different timezones

I have an app that allows users to schedule tasks. Users can set a schedule (schedule, an rrule string) as well as a timezone (scheduleTimeZone, a string e.g. Asia/Dubai). I am trying to write a function (getNextRunAt) that gets the next occurrence…
Andy Cloke
  • 63
  • 5
1
vote
1 answer

How to get the offset time when the timezone is known using moment.js?

Is there a way to know the offset time (how much ahead or behind the UTC/GMT), if I have the timezone value (for example 'America/Chicago') in momentjs or some other library in javascript?
AMATERASU
  • 63
  • 1
  • 5
1
vote
1 answer

Is it possible to convert timestamp to date and time using GMT offset as timezone in moment.js?

I have a couple of GMT time zones like this: GMT-06:00 GMT-05:00 GMT-04:00 Right now I am using this to convert a time stamp into a date and time like this: formatted = moment(timestamp).format('YYYY-MM-DD HH:mm:ss z'); Which returns something…
Onyx
  • 5,186
  • 8
  • 39
  • 86
1
vote
1 answer

Does moment.js allow me to derive a timezone abbreviation from this string "(GMT-10:00) Hawaii"?

I have an object with 2 properties available - timestamp and timezone, and they usually look something like this: time: { timestamp: 1576099544000, timezone: "Africa/Accra" } The problem is that sometimes it looks like this: time: { …
Onyx
  • 5,186
  • 8
  • 39
  • 86
1
vote
0 answers

How set a timezone in Chart js or avoid a DST issue

I have a chart js (2.9.4) based on measurements from around the globe. The API I call renders the dates in the local time of the measurement. That works fine but chart js has an issue with hours that don't exist, meaning when we skip one hour end of…
Dave Driesmans
  • 791
  • 1
  • 10
  • 21
1
vote
0 answers

Convert between Timezones

I am trying to convert between different timezones using momentjs but I can't get it right This is the code I am using: let Santiago = moment.tz("2006-01-03 08:00", "America/Santiago"); let london =…
Aisatora
  • 444
  • 6
  • 17
1
vote
1 answer

How to convert the local browser time to utc time unsing moment.js

Tried multiple methods to convert the local time to UTC. Tried Offset(420) as the time difference is UTC 7 and it worked. So here what i need is my users will be giving a request from different timezones and all of them should convert to UTC. So…
sai
  • 11
  • 1
1
vote
2 answers

How to get time difference moment js?

I want time difference between client and server. I used diff but getting this error "TypeError: date.diff is not a function" const date = moment(new Date()).format() const server =…
1
vote
0 answers

Unzone the toDate of a moment

My server is in UTC time. I create a localized date time in Los Angeles with moment like this: var m = moment.tz('2021-04-13T20:30:53-07:00', 'America/Los_Angeles'); This part works great. Doing m.date() gives me 13. However I need to give it to a…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
1
vote
0 answers

moment.tz using UTC

I am having a hard time trying to get my head around moment.tz, basically I am coverting a time to Europe/Zurich time moment .tz(moment(time), 'Europe/Zurich') .format() instead of this I would like to convert it on the…
Jgarnie
  • 431
  • 6
  • 20
1
vote
3 answers

Ordinal for day of the week

I want to format the date like below Tuesday, 2nd day of the week So, far I have done console.log(moment().format("dddd, Eo [day of the week]")) Cannot add 'Eo' to get ordinal. It does not format 'o', print as Sunday, 7o day of the week How can I…
bula
  • 8,719
  • 5
  • 27
  • 44
1
vote
1 answer

Make time independent of browser time zone

i am printing a timestamp in console of chrome browser using following code, moment("2021-01-12 00:00:00").utc().utcOffset(-new Date().getTimezoneOffset()).format('x') this line prints the timestamp at given time and date. if i change timezone from…
Khan M
  • 415
  • 3
  • 17
1
vote
1 answer

React js Moment Timezone has no data for IST

I have used moment-timezone in my react js project. date time conversion is showing correctly but Moment Timezone has no data for IST error is showing in console import moment from "moment-timezone"; export function utcToDate() { const zone_name =…
javed
  • 406
  • 3
  • 10