why chrome and firefox give different output in moment js?










2















could you please tell me why I am getting different output in chrome and firefox



code:
http://plnkr.co/edit/1wIvVISmgEqcRNnAD971?p=preview



execute this line



console.log(moment(moment("09-Feb-1983").format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())


Chrome gives: true

Firefox gives: false










share|improve this question



















  • 5





    "Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

    – Andreas
    Nov 13 '18 at 17:21











  • @Andreas so how i will solve this

    – user944513
    Nov 13 '18 at 17:22






  • 4





    Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

    – Andreas
    Nov 13 '18 at 17:23











  • it is already DD-MMM-YYYY format string

    – user944513
    Nov 13 '18 at 17:26






  • 1





    A suitable format string for parsing the string

    – Andreas
    Nov 13 '18 at 17:27















2















could you please tell me why I am getting different output in chrome and firefox



code:
http://plnkr.co/edit/1wIvVISmgEqcRNnAD971?p=preview



execute this line



console.log(moment(moment("09-Feb-1983").format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())


Chrome gives: true

Firefox gives: false










share|improve this question



















  • 5





    "Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

    – Andreas
    Nov 13 '18 at 17:21











  • @Andreas so how i will solve this

    – user944513
    Nov 13 '18 at 17:22






  • 4





    Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

    – Andreas
    Nov 13 '18 at 17:23











  • it is already DD-MMM-YYYY format string

    – user944513
    Nov 13 '18 at 17:26






  • 1





    A suitable format string for parsing the string

    – Andreas
    Nov 13 '18 at 17:27













2












2








2








could you please tell me why I am getting different output in chrome and firefox



code:
http://plnkr.co/edit/1wIvVISmgEqcRNnAD971?p=preview



execute this line



console.log(moment(moment("09-Feb-1983").format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())


Chrome gives: true

Firefox gives: false










share|improve this question
















could you please tell me why I am getting different output in chrome and firefox



code:
http://plnkr.co/edit/1wIvVISmgEqcRNnAD971?p=preview



execute this line



console.log(moment(moment("09-Feb-1983").format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())


Chrome gives: true

Firefox gives: false







javascript momentjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 18:18









Amy

21.6k1874131




21.6k1874131










asked Nov 13 '18 at 17:14









user944513user944513

3,2151258118




3,2151258118







  • 5





    "Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

    – Andreas
    Nov 13 '18 at 17:21











  • @Andreas so how i will solve this

    – user944513
    Nov 13 '18 at 17:22






  • 4





    Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

    – Andreas
    Nov 13 '18 at 17:23











  • it is already DD-MMM-YYYY format string

    – user944513
    Nov 13 '18 at 17:26






  • 1





    A suitable format string for parsing the string

    – Andreas
    Nov 13 '18 at 17:27












  • 5





    "Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

    – Andreas
    Nov 13 '18 at 17:21











  • @Andreas so how i will solve this

    – user944513
    Nov 13 '18 at 17:22






  • 4





    Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

    – Andreas
    Nov 13 '18 at 17:23











  • it is already DD-MMM-YYYY format string

    – user944513
    Nov 13 '18 at 17:26






  • 1





    A suitable format string for parsing the string

    – Andreas
    Nov 13 '18 at 17:27







5




5





"Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

– Andreas
Nov 13 '18 at 17:21





"Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release."

– Andreas
Nov 13 '18 at 17:21













@Andreas so how i will solve this

– user944513
Nov 13 '18 at 17:22





@Andreas so how i will solve this

– user944513
Nov 13 '18 at 17:22




4




4





Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

– Andreas
Nov 13 '18 at 17:23





Use a proper format or try to find a suitable format string: momentjs.com/docs/#/parsing/string-format

– Andreas
Nov 13 '18 at 17:23













it is already DD-MMM-YYYY format string

– user944513
Nov 13 '18 at 17:26





it is already DD-MMM-YYYY format string

– user944513
Nov 13 '18 at 17:26




1




1





A suitable format string for parsing the string

– Andreas
Nov 13 '18 at 17:27





A suitable format string for parsing the string

– Andreas
Nov 13 '18 at 17:27












1 Answer
1






active

oldest

votes


















0














Basically you are using a format that momentjs does not parse by default, so it fallsback to the native Date implementation. Which Chrome supports but not Firefox. You can see this if you put new Date("09-Feb-1983") in Chrome it will give you a date but in Firefox it will say invalid date.
All you need is to help moment js by giving the format as second parameter.



console.log(moment(moment("09-Feb-1983", 'DD-MMM-YYYY' /* <= This was added!*/).format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286326%2fwhy-chrome-and-firefox-give-different-output-in-moment-js%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Basically you are using a format that momentjs does not parse by default, so it fallsback to the native Date implementation. Which Chrome supports but not Firefox. You can see this if you put new Date("09-Feb-1983") in Chrome it will give you a date but in Firefox it will say invalid date.
    All you need is to help moment js by giving the format as second parameter.



    console.log(moment(moment("09-Feb-1983", 'DD-MMM-YYYY' /* <= This was added!*/).format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())





    share|improve this answer





























      0














      Basically you are using a format that momentjs does not parse by default, so it fallsback to the native Date implementation. Which Chrome supports but not Firefox. You can see this if you put new Date("09-Feb-1983") in Chrome it will give you a date but in Firefox it will say invalid date.
      All you need is to help moment js by giving the format as second parameter.



      console.log(moment(moment("09-Feb-1983", 'DD-MMM-YYYY' /* <= This was added!*/).format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())





      share|improve this answer



























        0












        0








        0







        Basically you are using a format that momentjs does not parse by default, so it fallsback to the native Date implementation. Which Chrome supports but not Firefox. You can see this if you put new Date("09-Feb-1983") in Chrome it will give you a date but in Firefox it will say invalid date.
        All you need is to help moment js by giving the format as second parameter.



        console.log(moment(moment("09-Feb-1983", 'DD-MMM-YYYY' /* <= This was added!*/).format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())





        share|improve this answer















        Basically you are using a format that momentjs does not parse by default, so it fallsback to the native Date implementation. Which Chrome supports but not Firefox. You can see this if you put new Date("09-Feb-1983") in Chrome it will give you a date but in Firefox it will say invalid date.
        All you need is to help moment js by giving the format as second parameter.



        console.log(moment(moment("09-Feb-1983", 'DD-MMM-YYYY' /* <= This was added!*/).format('DD-MMM-YYYY'), 'DD-MMM-YYYY', true).isValid())






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 17:38

























        answered Nov 13 '18 at 17:27









        MotKohnMotKohn

        1,463926




        1,463926



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286326%2fwhy-chrome-and-firefox-give-different-output-in-moment-js%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党