Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sameer Siddiqui
    @SameerSiddiqui
    p0y0m0dt0h0m0s What is this time format called ?
    how i can convert dateTime in to above is there a func avail in moment ?
    Eder Gomez
    @Ederagp
    @bmwertman try import * as moment from "moment"
    Keegan
    @Keggatron
    Hey guys, anyone know if it's possible to show a separate month date if and only if the month changed in the time interval. ie Nov 11 - 17, but if a month changes during any week interval to then show the month? ie Nov 25 - Dec 1
    Joseph Maxim
    @josephmaxim
    After adding moment.js client side in my react app my build load time tripled. is it not recomended to use clioentside?
    Raja Simon
    @rajasimon_gitlab
    const result = currentTime.to(startTime); // In a day

    But I need to know exact days, hours, minutes, seconds like this 3, 18, 55, 60

    How do I achieve this? Hey by the way it's awesome library.

    Eder Gomez
    @Ederagp
    @rajasimon_gitlab you can use:
    moment(datetime).format("DD"); // result day
    moment(datetime).format("MM"); // result month
    moment(datetime).format("YYYY"); // result year
    moment(datetime).format("HH"); // result hour
    moment(datetime).format("mm"); // result minutes
    moment(datetime).format("ss"); // result seconds
    Raja Simon
    @rajasimon

    @Ederagp Thanks for your valuable answer but in your answer you used datetime to convert into desirable format. In my case I've two datetime and I need to know the time difference between two datetime in the format of ( years, months, dates, hours, minutes).

    const currentTime // Moment {_isAMomentObject: true, _i: "2018-11-24T10:00:00+05:30", _f: "YYYY-MM-DDTHH:mm:ssZ", _tzm: 330, _isUTC: false, …}
    const startTime // Moment {_isAMomentObject: true, _i: Fri Nov 23 2018 13:41:56 GMT+0530 (India Standard Time), _isUTC: false, _pf: {…}, _locale: Locale, …}

    Now that I know currentTime and startTime and I need to know the time difference and after digging through the momentJs docs I found that I can use to like this

    const result = currentTime.to(startTime) 

    but above code return In a day but what I want is years, months, hours, minutes, seconds Please help me to understand how to get this desirable format what I want.

    Eder Gomez
    @Ederagp
    @rajasimon since you know currentTime and startTime you can use, as explained in moment().diff():
    moment().diff(Moment | String | Number | Date | Array);
    Obtaining the difference can pass the unit of measurement required days, month, year, hour, minutes, seconds:
    a.diff(b, 'years');
    a.diff(b, 'days');
    Francis Rodrigues
    @francisrod01
    What's the best way to create a JS class/component (if use React) to reuse a moment instance?
    adrianwood
    @adrianwood
    Is there a reason why the latest versions of spam-moment are not published to NPM?
    *spm
    Joel Costa
    @joelrfcosta
    @mj1856 on moment/moment#1407 you said to talk with you so here it goes :)
    Is there any way to disable the warning during tests?
    Joel Costa
    @joelrfcosta
    Ok, found out how to do it right: moment.utc(dateString, moment.ISO_8601, true). Thanks :)
    Trent Jones
    @FizzBuzz791
    Hi all, when I do something like this; moment.duration("P240M") it returns a duration object that has converted it to 20 years... Not wrong, but a little frustrating when I want .humanize() to return "240 months"... Am I missing something or my specific use-case is just a PITA?
    Daniel Jones
    @DanielDarrenJones
    Hey guys, I am parsing the string "1968-11-12T23:00:00.000Z" on two different devices, one is a mac and the other an Iphone and will say the day is 12th Nov 1968 while the other is Saying its the 13th, the locale on both appears to be GMT, what could be causing this?
    Sorry the locale is "en" on both
    Daniel Lizik
    @daniellizik
    anybody else have issues with jordan/amman timezone on safari?
    coming across a very strange bug
    Brad Wertman
    @bmwertman
    I'm having some trouble with date/time formatting. On my client I use moment(myDateObject).format('h:mm a') and check the output and I have what is expected, something like "7:53 am". I then use my socket.io connection to send that to my Raspberry Pi running on the same network locally and store it in a variable. When my client restarts it emits an event to my Rpi asking for the value to be returned. But what I get back isn't formatted as it was when I sent it. Instead it looks like "2019-02-08T12:53:22.000Z". Do I need to do something extra to grab the formatted date from Moment before sending it?
    kevin olson
    @acidjazz
    moment().month(moment().format('M')).format('MMMM’)
    why does this give me March
    HeiVask
    @HeiVask
    @acidjazz Because moment().format('M') returns 2 and months in javascript go from 0 to 11, so 2 represents March.
    Roy Hvaara
    @hvaara
    Hi. Is there a way to check if a string is a valid iso8601 duration? (Eg. PT15M -> true, foo -> false)
    HeiVask
    @HeiVask
    moment('2013W065', moment.ISO_8601).isValid(). Check docs to see supported strings.
    kevin olson
    @acidjazz
    @HeiVask so ill ask since it seems like i have to, why would moment accept a month numeric as not 0-11, but spit out a month numeric as 0-11
    HeiVask
    @HeiVask
    Because moment uses tokens to create instances and format values. For get/set methods it uses real values.
    Arjun Biju
    @Arrow66
    hi guys
    any way to convert date time to "2018-10-04T11:54:07.000Z" format
    ?
    moment("2018-10-04 11:54:000").format("YYYY-MM-DDTHH:mm:ss.SSSSZ")
    results 2018-10-04T11:54:00.0000+05:30 this one
    but i need datetime to be in 2018-10-04T11:54:07.000Z format with z
    Arjun Biju
    @Arrow66
    some one help me out
    HeiVask
    @HeiVask
    @Arrow66 AFAIK, Zulu is GMT, so can you append it simply as a string? like moment("2018-10-04 11:54:000").format("YYYY-MM-DDTHH:mm:ss.SSS[Z]") :s
    Ihsan Katmer
    @ihsankatmer
    hi everyone, i am trying to install moment.js I type npm install moment --save but after I the addition app crashes. any idea?
    Artem Biryukov
    @impowski
    Guys I have a problem with timezones on server
    I have users in my database with a field timezone which I'll utilize later
    The client sends hours in this format to server 19:30 then I take a user and his timezone and convert this time back to UTC
    Since my server is in UTC it's impossible to convert it to 16:30 I suppose
    Aubrey Quinn
    @aubrey-fowler
    Hi all, can you help me out? When I call this function moment('01-01-2017', 'DD-MM-YYYY').startOf('month').week()
    I get different results even when the locale is the same
    in my project and browser I get 53 but in another browser i get 1 https://stackoverflow.com/questions/55724982/momentjs-returning-a-different-result-in-browser-than-in-karma-unit-test
    Eugene Serkin
    @jeserkin
    Hey guys, does anybody know, how to use moment-timezone with latest angular?
    Rodo Abad
    @rodoabad
    Is there a reason why if I do console.log(moment()) in a Node environment that it returns moment(<current data/time>) instead of executing like in a browser environment?
    Where it gives the actual Moment object?
    Shreedevi-G-Rao
    @Shreedevi-G-Rao
    Hi all,
    i am using moment('2019-05-21T07:05:11.5685421-07:00').format('MM/DD/YYYY HH:MM:SS') function which is giving wrong time as '05/21/2019 08:05:11' even after changing time zone to (UTC-07:00)Mountain Time(US & Canada) . It should be 07:05:11. Please help me out to get the right time.
    Guri107
    @Guri107
    Hi all,
    We working on accessibility fixes for client. Bug is role is missing for previous and next button of date picker. We using moment -2.8.3. Please let me know that above issue is fixed or not if fixed in which version.
    Dawid Paweł Sowa
    @owlcode
    Hello guys, I need to format duration and I wonder if moment.js can help me with that. I want to have it localized and in different subject so not "time passed: 3 hours 2 minutes 10 seconds"
    but rather "logged out after: 3 hours 2 minutes 10 seconds". Problem is, in different languages you spell these two cases differently (not like in English, where it's the same). Does moment.js has support for something like that, or do you know any other library that might be helpful?
    Dawid Paweł Sowa
    @owlcode
    I'm currently leaning towards changing translation so that default moment.js format fits but I wonder if that would be possible
    Vipul Kapoor
    @VeeK727
    Hi Guys. I'm having a wierd issue. I'm trying to using moment in my custom plugin but I get an error moment is not a function. I've looked around but didn't find a solution. Do I have to do something special for it to work inside a plugin definition?
            console.log(moment()); //works
        $.fn.datepicker = function(options){
            console.log(moment()); //doesn't work
        });
    Dawid Paweł Sowa
    @owlcode
    Hello, assigning anonymous function may cause problems with this. Try doing
     $.fn.datepicker = (options) => {
            console.log(moment()); 
        });