datetime - Displaying local time from ISO 8601 string with Momentjs -
i want display local time iso 8601 string using momentjs. there discrepancy of minutes when convert iso string using different date formats. if use 'mm/dd/yyyy hh:mm', minutes correctly displayed. if use 'ddd, mmm hh:mma', 11 minutes added (in case).
my sample js (babel) code:
let today = moment('11/09/2016 00:00', 'mm/dd/yyyy hh:mm').toisostring(); //today = 2016-11-09t08:00:00.000z let formatted = moment(today, moment.iso_8601).format('mm/dd/yyyy hh:mm'); //formatted = 11/09/2016 00:00 let formatted2 = moment(today, moment.iso_8601).format('ddd, mmm hh:mma'); //formatted2 = wed, nov 9th 00:11am
i prefer using second format. can explain why there discrepancy?
please see fiddle: https://jsfiddle.net/anudhagat/8fgtjbc7/3/
i caught silly mistake. have capitalized minutes in second format, using mm makes display months instead of minutes.
Comments
Post a Comment