Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    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!
    Kemal Ahmed

    I'm using moment timezone in typescript using bower and really struggling to import it. I used

    import { moment } from '../../../bower_components/moment/min/moment-with-locales.min.js';
    import {moment as momentTimezone} from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';

    this gives Uncaught TypeError: moment.tz is not a function

    and sometimes I was getting Uncaught TypeError: (c || "").toLowerCase is not a function but I don't remember what I did to make it do that.

    Kemal Ahmed
    Ok I figured it out. My issue was a javascript issue and this format actually works fine. I was setting the initial value of a property of a web component to return (() => moment.tz.guess()). Changed it to return moment.tz.guess()

    I'm using moment timezone in typescript using bower and really struggling to import it. I used

    import { moment } from '../../../bower_components/moment/min/moment-with-locales.min.js';
    import {moment as momentTimezone} from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';

    this gives Uncaught TypeError: moment.tz is not a function

    and sometimes I was getting Uncaught TypeError: (c || "").toLowerCase is not a function but I don't remember what I did to make it do that.Actually my second line of code was:

    import { moment as moment.tz } from '../../../bower_components/moment-timezone/builds/moment-timezone-with-data.min.js';
    Hi I have this 2/14/2018 5:00 AM and it is timezone -07:00
    the computer is on time zone +04:00
    when I use moment with (2/14/2018 5:00 AM) instead of it seeing it as -07:00 it converts to +04
    how can I tell moment my datetime is 2/14/2018 5:00 AM and it is timezone -07:00
    Manish Chandra
    Hi All
    Manish Chandra
    I am using moment-timezone ver: 0.5.14 and @types/moment-timezone ver: 0.5.4 and json-loader ver: 0.5.7
    Using webpack as build tool
    Server side I am able to use moment-timezone
    but on client side its giving error Uncaught TypeError: Cannot read property 'length' of undefined at addZone (moment-timezone.js:385) at Function.loadData [as load] (moment-timezone.js:456) at Object.hasOwnProperty (index.js:2) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.module.exports (client.bundle.js:10625) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.<anonymous> (driver-header-container.tsx:9) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19) at Object.<anonymous> (fetch.js:461) at __webpack_require__ (bootstrap 93e619d9be8d81d31053:19)
    Basically with above moment -timezone is not able to read ./data/packed/latest.json
    My web pack config
    Client ---