I pass a date string
2015/05/14-02:55 pm to moment.js constructor and i am using
fromNow to convert it into a readable format. When i run this command on 16th May, chrome displays right output but mozilla says
a few seconds ago.
firefox console output:
chrome console output:
Is this a problem with my mozilla time settings? I ran
Date() on mozilla console. It correctly printed the date as:
"Sat May 16 2015 15:18:02 GMT+0530 (IST)"
Best How To :
You are creating the
moment from a String, and it is not recommended:
Warning: Browser support for parsing strings is inconsistent. Because there is no specification on which formats should be supported, what works in some browsers will not work in other browsers.
For consistent results parsing anything other than ISO 8601 strings, you should use String + Format.
Just pass the format as the second parameter and it will show correctly on any browser:
moment('2015/05/14-02:55 pm', 'YYYY/MM/DD-HH:mm A').fromNow()