Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Daniel Einspanjer
    Hi folks, I'm hoping someone could help me debug a problem with not getting tz data loaded.
    I'm in a bit of a weird environment though. I'm running inside the Postgres plv8 extension.
    I'm using a project called node-plv8 that allows me to install node modules inside plv8 so they can be required and used as normal packages (assuming they don't make use of unsafe features like xhr and such
    I did an npm install moment moment-timezone, and they are available, but moment("2015-01-01T00:00:00 America/New_York") returns null whereas moment("2015-01-01T00:00:00-05:00") works
    Looking in the node_modules directory, I see a builds directory that contains the -with-data* that I imagine I want, but I'm unsure how I would go about requiring that variant of it.
    Daniel Einspanjer
    Ah.. I see in index.js that it does a moment.tz.load(require('.data/packed/latest.json'));. I wonder if maybe that is what is tripping up the plv8 loader
    Daniel Einspanjer
    Oh geeze.. it looks like the tz data is loaded fine.
    the problem appears to be that I'm trying to do moment("2015-01-01T00:00:00 America/New_York"). I just tested moment.tz("2015-01-01T00:00:00", "America/New_York") and that works fine.
    Matt Johnson-Pint
    Sorry, I don't jump on Gitter often enough.... @abhijit945, See my response on your #456
    @evansiroky @ssskip - Thanks. I'll merge and do a release soon
    @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-Pint
    @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-Pint
    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-Pint
    @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-Pint
    @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-Pint
    @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-Pint
    @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