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
4
votes
2 answers

Reset timezone aware timestamp momentjs

I am using momentjs for doing my date operations and want to code a scenario where if timestamp is given, and timezone name is given, then I want to reset the time to midnight. For e.g. let timestamp = 1493638245234; expect(new…
Neha M
  • 443
  • 1
  • 4
  • 13
3
votes
2 answers

Moment returning an invalid date while using Hermes JS Engine

When I was using jsc Engine, everything was working fine but when I shifted from jsc engine to Hermes Engine in my react native app I started getting Invalid date where I was using moment. CODE: const defaultDate =…
sakshya73
  • 5,570
  • 5
  • 22
  • 41
3
votes
2 answers

moment().isValid returns true when the input is in integers

Code: let modifiedValue = attribute_value; let isISOFormat = moment(new Date(attribute_value), moment.ISO_8601, true).isValid(); if (isISOFormat) { modifiedValue = formatDateShortCustom(moment(attribute_value).toDate()); } return…
3
votes
1 answer

Valid IANA timezone list

I'm working on an Nodejs system support multi timezone users. Currently, I'm using moment.tz.names() to get list of available timezone. But I found out that some timezone in list is deprecated by this link. I also found this database from IANA. So…
Nguyen Hoang Vu
  • 751
  • 2
  • 14
  • 35
3
votes
2 answers

Time format change according to time settings of phone in ionic5 angular9

I need to parse the time according to the phone settings(both android and IOS). If I select 24 hours in the device, need to show the 24 hour date in application and for the 12 hours selection, need to show the 12 hour time format in application. How…
3
votes
0 answers

How to use cypress with moment-timezone

Cypress has the moment library imported into its API and can be accessed by Cypress.moment(date) https://docs.cypress.io/api/utilities/moment.html#Syntax But I need to use moment-timezone instead of moment in the test to use switch between…
MCFreddie777
  • 1,069
  • 1
  • 12
  • 21
3
votes
1 answer

Moment timezone: Local Timezone gets applied to parsed date but not on format()

Context: I have a server hosted on a VM in the cloud. When using just the moment library to initialize dates I always get a date which has +- some hours. After a quick research, I found the moment-timezone library which should solve this issue but I…
iDaniel19
  • 75
  • 7
3
votes
2 answers

How can I set correct timezone for a date field in Mongoose?

I'm using moment for generating time and date: const moment = require('moment-timezone'); const emailModel = require('./api/models/emails'); sentTime=moment().tz('America/Los_Angeles').format(); console.log(sentTime); //console log shows…
samurai_code
  • 57
  • 2
  • 9
3
votes
0 answers

Moment Timezone has no data for UTC

I am importing moment-timezone like this: import * as moment from 'moment-timezone/moment-timezone'; Vue.prototype.moment = moment; And I add UTC values like: // copied from latest.json in moment-tz…
senty
  • 12,385
  • 28
  • 130
  • 260
3
votes
3 answers

Mock using jest moment().format is returning current date instead of mocked date

I am trying to mock moment library's format function using jest. I have following code in my test file. app.spec.js: jest.mock('moment', () => { const moment = () => ({ format: () => mockedTime }); moment.tz = { …
3
votes
2 answers

How to get local time of different timezone in Postman?

I want to get local time of Rome time zone. Didn't find any details on how to use moment sandbox built-in library in postman documentation here postman_sandbox_api_reference what I have tried so far var moment =…
Dev
  • 2,739
  • 2
  • 21
  • 34
3
votes
1 answer

moment-timezone America/Sao_Paulo wrong timezone offset

I'm getting an error using moment-timezone with America/Sao_Paulo trying to parse date with America/Sao_Paulo offset. I've created this code: const date = "2019-1-1 23:30"; const format = "YYYY-M-D HH:mm"; const timezone = "America/Sao_Paulo"; const…
Pedro Arantes
  • 5,113
  • 5
  • 25
  • 60
3
votes
3 answers

Using timezones with @nuxtjs/moment

We use the @nuxtjs/moment (https://www.npmjs.com/package/@nuxtjs/moment) package in our nuxt application. In our app we want to display GMT-timestamps in the users timezone like so:
{{ $moment("2019-04-25 19:01:03").fromNow() }}
But on…
Crack_David
  • 2,775
  • 1
  • 14
  • 30
3
votes
3 answers

Generate ics with dynamic VTIMEZONE using moment js

Trying to create a .ics file which has a VTIMEZONE component, which based on the supplied timezone sets the Standard time and Daylight Savings time dynamically. Just a…
3
votes
4 answers

Momentjs showing the same time for multiple time zones

So I'm trying to get various time zones, and I have set up the times, however, the same time is being displayed in all zones. Here is my code: const format = 'HH:MM' // San Francisco - Time let sanFrancisco =…
user8331511
1
2
3
26 27