But in IE it is having issues, from this I understood we can apply one dateformat on the given date, If we want second date format, it should be apply on the fresh date not on the first date format result.Īnd also observe that for first time applying 'MM-DD-YYYY' and next 'MM-DD-YY' is working in IE. Then, when I use another format on "06/28/20": startDate = moment(startDate ).format('MM-DD-YYYY') Result: 06-28-1920, in google chrome and firefox browsers it gives correct date on second attempt as: 06-28-2020. moment ().format () moment ().format (String) Observe the following examples to gain a better understanding on displaying date using the format method. The result is "Mon 00:00:00 GMT+0530 (India Standard Time)", What happening is it retains only the year part :20 as "06/28/20", after If I run the statement : Var startDate = moment(new Date()).format('MM/DD/YY') Result: 06/28/20 It can display date in JSON format, Array, Object, String etc. There are methods available which tells the time from a given moment, from the current moment, difference between two moments etc. I am using moment.js format function on a current date as (today is 29-06-2020) MomentJS provides formats to display date in different ways. May be this helps some one who are looking for multiple date formats one after the other by willingly or unexpectedly. Stack Trace: at makeDateFromStringAndFormat ()Īt _personal.rendered () I should also mention that I am using a pre-packaged version of Moment.js, packaged for Meteor.js Object has no method 'replace' : The Exact error from the console There are three types of formatting capabilities: Technical formats like ISO 8601 and RFC 2822 Internationalizable human-readable formats Token-based formatting Technical formats (strings for computers) ISO 86 is the most widely used set of string formats for dates and times. date-fns is one of the best lightweight libraries, it's modular, so you can pick the functions you need and reduce bundle size ( issue & statement ). Which errors and says there is no such method called replace? Am I approaching this in the wrong way? Moment is great time manipulation library but it's considered as a legacy project, and the team is recommending to use other libraries. I tried to do it using this method, moment(testDate,'mm/dd/yyyy') I would like to use Moment.js get it in this format mm/dd/yyyy : for display. I have a string in this format: var testDate = "Fri 19:08:55 GMT-0500 (CDT)"
0 Comments
Leave a Reply. |