Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Hi everyone!
    'DD/MM/YYYY \n H:mm' format outputs 09/04/2018 12:24,
    how can i get a line break between the date and the time?

    Hey guys
    I have a weird issue
    I have a string ISO date, lets call it startTime
    I also have a duration string, in the format of 'HH:mm:ss'
    I need to calculate the endTime as startTime + duration

    I am trying to do this like this:
    const endTime = moment(startTime).add(moment.duration(duration))

    but I keep getting the startTime unchanged as a result
    Mark Carpenter Jr
    Try establishing the duration object first and then use it inside the add function.
    Allan Ebdrup
    Hi. Moment is awesome, thanks for all your work!
    Regarding the deprecation warning: https://stackoverflow.com/questions/23263380/deprecation-warning-moment-construction-falls-back-to-js-date?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
    I am intentionally feeding moment an invalid string 'NotValid' in my tests to make sure it doesn't work. This outputs the deprecation warning and messes up my test output. Is there any way to suppress the deprecation warning when running tests?
    Oh finally found it: moment.suppressDeprecationWarnings = true; right?
    @mcarpenterjr thanks, that helped me :D
    Murat Aksoy
    Hi guys, I'm having a problem using utc and toDate functions.
    I try to get UTC date time as javascript Date object so I use :
    moment.utc().toDate() it returns my local time but if I use moment.utc().format("YYYY-MM-DD HH:mm"); then I get the UTC date time but just a string
    what can I do ?
    Matt Scheurich
    Hiya guys. I just wanted to ask a question regarding moment.startOf and moment.endOf in relation to locale and Middle Eastern countries. It seems there are a few (about 15 from my calculations) which start on a Saturday...
    I don't know how accurate this chart is, but it's currently the only source of info that I can find with some kind of tabular data connecting country names to start of the week: http://chartsbin.com/view/41671
    Matt Scheurich
    I also did some quick normalisation (in conjunction with a gist I found online of ISO 3166-1 alpha-2 country codes) and further processing of the data: https://codepen.io/lvl99/pen/qYWVmd
    Maybe there's some thing more complex here as it's more to do with a country than a locale, right?
    Or maybe there's some shared locale information, I'm not sure
    Matt Scheurich
    it's probably already in the code anyway
    Muhammad Sohail
    Angular Cannot find name 'moment'.
    Elvis Begović
    It seems moment isn’t tree sheakable lib
    All locales are in my bundle very annoying, any way avoid this? In ts project for browsers
    Mike Escalante
    I'm getting a custom string back from someone that i need format - it looks like "201608051348" which is "YYYYMMDDHHMM"... this is NOT an ISO format, and I can't seem to figure out how to parse this... is Moment going to work for that or should I just write something from scratch and parse it as a Date()
    moment('201206130139', 'YYYYMMDDHHmm') worked... i was using MM because i haven't had enough coffee
    Sharikov Vladislav


    What is correct way to use momentjs for DATE ONLY case? DATE ONLY = date without time ?

    For instance, for the CALENDAR component (without date). How to create momentjs object without time or how to detect momentjs object was initiated without time?

    Sharikov Vladislav
    Is is possible to get initial format if momentjs object was initiated with ISO string?
    Sharikov Vladislav
    moment('2024-12').endOf('month').add(-12, 'hours').format('W')
    Both of these result to 1. Why? It must be something like 52.
    Sharikov Vladislav
    I got it. Thank you.
    Hallvord R. M. Steen
    I'm seeing a very weird test failure that boils down to moment-timezone returning an unexpected date :(
    The test uses proxyquire to stub some APIs. This seems to be significant.
    and it seems significant that some of the server files used require('moment') while the test used require('moment-timezone')
    Code attempts to find next spring's DST change date for Oslo/Norway this way: moment().tz('Europe/Oslo').add(1, 'year').month(2).endOf('month') .weekday(0)
    Hallvord R. M. Steen
    now, this is very strange: if proxyquire runs before this code, and sets up a server with APIs that do require('moment'), the calculation above ends up with an unexpected date!?? March 25th 2019 (a Monday) rather than the expected 31st.
    Mark Carpenter Jr
    Do you know what version of moment the proxyquire server is requiring? The docs state that moment-timezone depends on moment 2.9.0+. Could also be a bug in between 2.9 and the current release, if the deps haven't been updated.

    The docs say the following:

    Note: if you chain multiple actions to construct a date, you should start from a year, then a month, then a day etc. Otherwise you may get unexpected results, like when day=31 and current month has only 30 days (the same applies to native JavaScript Date manipulation), the returned date will be the 30th of the current month (see month for more details).
    Bad: moment().date(day).month(month).year(year)
    Good: moment().year(year).month(month).date(day)

    Based on that information I would expect:
    To print: "2018-04-30T13:20:40-04:00”
    But instead it prints: "2018-05-01T13:20:40-04:00”

    Ivo Raisr
    I am seeing weird test failures for all locales, when run with 'grunt test'. The environment has been setup as per CONTRIBUTING.md. Here is one manifestation of this problem:
    Died on test #1 at global.test.QUnit.test (/home/iraisr/moment/node_modules/node-qunit/lib/child.js:133:21)
    at /home/iraisr/moment/build/umd/test/locale/cs.js:553:5
    at test (/home/iraisr/moment/build/umd/test/locale/cs.js:4:43)
    at Object.<anonymous> (/home/iraisr/moment/build/umd/test/locale/cs.js:7:2)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32): undefined$S is not defined
    ReferenceError: undefined$S is not defined
    at prepareConfig (/home/iraisr/moment/build/umd/moment.js:2560:43)
    at createFromConfig (/home/iraisr/moment/build/umd/moment.js:2544:44)
    at createLocalOrUTC (/home/iraisr/moment/build/umd/moment.js:2631:16)
    at createLocal (/home/iraisr/moment/build/umd/moment.js:2635:16)
    at hooks (/home/iraisr/moment/build/umd/moment.js:12:29)
    at Object.<anonymous> (/home/iraisr/moment/build/umd/test/locale/cs.js:554:22)
    I was not able to find anywhere how those 'undefined$..' variables are constructed...
    Ivo Raisr
    This problem manifests also in CI-Travis builds, for example:
    Robert Stiffler
    I'm seeing behavior with the .isAfter() method that I'd like to confirm is unexpected before I make a bug report. It looks like the comparison with day-granularity (moment1.isAfter(moment2, 'day')) depends upon the locale of moment1 to determine if the day number is equal.
    for example
    moment(new Date('2018-07-03T03:00:00.000Z')).isAfter(new Date('2018-07-03T00:00:00.000Z'), 'day') //false
    this is false because my locale is GMT-4 so '2018-07-03T03:00:00.000Z' is actually Jul 02 in my locale
    Robert Stiffler
    moment(new Date('2018-07-03T04:00:00.000Z')).isAfter(new Date('2018-07-03T00:00:00.000Z'), 'day') //true
    However, if I set UTC mode, the result changes
    moment(new Date('2018-07-03T04:00:00.000Z')).utc().isAfter(new Date('2018-07-03T00:00:00.000Z'), 'day') //false
    Kodie Grantham
    Hi! I've posted on here before and also on GitHub and have gotten zero responses. I'd really like to update my plugin along with another plugin of mine but I need some input regarding this: moment/momentjs.com#439
    Hi Guys
    anybody here?
    Neil Stevens
    Is there anyway to set the meridian on a moment object
    Scott O'Toole
    Weird bug: I'm developing a phone gap app, and I'm able to reference moment if I spin it up in the browser. However, when I run it on device or an iOS simulator, moment is not defined. What's deal?
    Disclaimer: I'm not a super advanced developer, so I may be missing something completely unrelated to moment.
    This is probably related... now I'm just looking for a solution: As of version 2.10.0, the moment global is no longer available if a module system is detected. This was previously working in 2.9.0.