Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Matt Johnson
    @deinspanjer - yep, we don't have any way for moment's parser to fish out a time zone id and call into moment-timezone. You have to call it directly.
    Yonatan Kogan
    I'm going to take a quick stab at moment/moment-timezone#208
    if that's a mistake for some reason, let me know, haha
    Yonatan Kogan
    Andddd bailed. I'd like to come back at some point however
    Chi Nguyen
    if i create a moment with moment(1494595195,'X') it return a valid one, but when i set default timezone moment.tz.setDefault(America/Los_Angeles) for example and create same moment, it return an invalid Date
    Matt Chandler

    I'm stuck on a problem and would really appreciate some help.

    I'm trying to use moment-timezone to schedule an event based on the users time zone. ie, User lives in Denver and should receive a push notification at a given time, regardless of the servers time. I have the users time zone and their chosen delivery time/date. No matter what I do, I can't get it to work. I know I'm missing something small, but this is killin' me lol

    Matt Johnson
    @mchandleraz - not sure how to help you. "I can't get it to work" isn't a very good description of the problem. Paste a code snippet here, or ask (with supporting details) on StackOverflow. Thanks.
    @midori0507 - I wasn't able to reproduce that. It works for me. (I assume you meant to put quotes around the time zone id)
    Prithwiraj Sinha
    Hi, Is there a way to check if a timezone identifier e.g. 'America/Chicago' is valid using moment timezone ?
    The thing I am trying to do is this - If the timezone identifier provided is valid, use it otherwise fallback to a default timezone identifier value. And for that I am not seeing any straightforward way of doing it. Please help.
    Matt Johnson
    if (!moment.tz.zone('America/Los_Angeles')) {
      // zone doesn't exist, or is not loaded.
    } else {
      // zone exists and is loaded.
    Peter Bailey
    How do you stop moment-timezone adjusting times for daylight saving that have already been adjusted? London times entered are having the hour incremeneted
    Peter Bailey
    Think it might’ve been because I was using a unix timestamp
    Matt Johnson
    @pea - you'd have to show me some example code
    Raja Marimuthu
    i have date moment.tz().toISOString()
    value is 2017-06-16T13:10:02.180Z
    how do i convert unix timestamp
    Matt Johnson
    @sraja83_twitter - You don't need moment-timezone for that. That's just equivalent to moment().toISOString(), or moment.utc().toISOString().
    If you want the current unix timestamp in seconds, that's moment().unix(), or in milliseconds that's moment().valueOf(), or just +moment()
    If you meant how to go from the ISO string to unix time, then parse it first, as in moment("2017-06-16T13:10:02.180Z").unix() or moment("2017-06-16T13:10:02.180Z").valueOf() or +moment("2017-06-16T13:10:02.180Z")
    has anybody used anime.js ?
    Sayan Bhattacharya
    How do i load timezone data to moment-timezone when I am using it in the server side?
    classic example of momentJS with Angular2 with table format:https://github.com/agnel123/MomentJSAngular2.git
    Hi everyone, any chance timezones via .format('z') using moment-timezone are localised? An example, CET in English, but MEZ in German.
    Matt Johnson
    @runnererr_twitter - nope. Our abbreviations come from IANA. You'll only find localized forms in CLDR data. Though even there, time zone abbreviations are grosly under-represented.

    Hello, I'm just looking to contribute. Here is a regular expression to parse the timezone from a date/time string. It works with the new and old format strings.

    "date.toString() or date.toTimeString()".replace(/^.* (\([A-Za-z ]+\)|[A-Z]{3}).*$/, '$1').replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, '$1$2$3');

    Credit goes to "Mootools More" Date module but I had to modify the first RE since it didn't work with the new string format.

    Mario Contreras
    Hey guys, I do not know where to ask. But I have a doubt, when I am creating a moment date using moment() and moment.tz() with my actual zone the dates differs by 6 hours, is this behaviour normal?
    suneel bandhu

    Hi I am trying to print the following output but unable to do so,can anyone help to point out where I am wrong?
    Expecting Output = "Atlantic Standard Time"

    var now = new Date();
    var month=now.getMonth();
    var year = now.getFullYear();
    var timeZoneName=moment.tz([year,month],timeZone).format('zz');

    Actual Output: "AST"

    Matt Johnson
    @bandhu_suneel_twitter - Moment-timezone doesn't have that sort of string.
    I have added dependency in bower.json "moment-timezone" : "0.5.14". Is there any way I can load moment-timezone-with-data.js instead of moment-timezone-with-data-2012-2022.js?
    I have a UTC time in milliseconds from epoch. I would like to use moment-timezone to return a timezone specific seconds since epoch representation. I see examples using .format to return, but I am overlooking the call to return seconds since epoch.
    Bharat Soni

    Hi, I am using timezone to convert the date into different time zone, this is how I am doing it:


    I am getting error: moment().tz is not a function. I am importing moment using es6 modules, do I need import time zone too? If yes, how do I do that..

    @iiison you probably need
     const moment = require('moment-timezone');
    Manish Chandra
    Hello all
    I am using moment-timezone for my company
    new Date() = Thu Jan 18 2018 12:26:00 GMT+0530 (IST) --> current time 
     moment.tz(this.props.driver.timezone) ->  Moment {_isAMomentObject: true, _isUTC: true, _pf: {…}, _locale: Locale, _d: Thu Jan 18 2018 06:27:03 GMT+0530 (IST), …} 
    timeZone = "America/Chicago"
    Its happening in a weird way , moment.tz first converts time into "America/Chicago" timezone and then adds 5:30 min according to IST
    Manish Chandra
    But if I use moment.tz(this.props.driver.timezone).format('MMMM Do YYYY, h:mm:ss a'). It gives correct result January 18th 2018, 12:53:32 am (this is few minutes older as compared to output of new Date())
    Hua Lu
    Hello all, how can i tell some date is valid or not under certain locale with momentjs?
    Jon New
    This might be the better room for my question. Is there a way to detect if a given timezone is valid with moment? I see it logs an error when it doesn't recognize, but is there anything I can use programmatically?
    Matt Johnson
    @chandrajob365 - See http://momentjs.com/guides/#/lib-concepts/internal-properties/ (Basically, you should not consume any property prefixed with an underscore).
    Bernhard Grünewaldt
    @mj1856 I was trying to add tz 2018c but now 300 tests fail => clouless/moment-timezone@fbe7ae4
    Should I correct the tests? Most tests seem to "guess" random stuff which does not seem to be deterministic. I read everything in contributing.md about data and all worked. Except now a lot of tests fail. On the develop branch 6 Tests fail anyway.
    Matt Johnson
    @clouless - Step 8 in the contributing doc describes how tests are rebuilt with grunt data-tests. Yes - there's a degree of randomness to it at present.
    There's also more than just building the data and tests to prep a release, so I can take care of all of it if you like. Though thanks for reminding me.
    If you weren't aware, 2018a and 2018b were recalled, so first true release of this year is 2018c. The main change being for Sao Tome.
    Bernhard Grünewaldt
    @mj1856 ok that would be great :) thanks a lot for your effort!