Why Is Iphone Ios Showing Invalid Date For Momentjs
I have a datepicker which was returning a moment object that was always in UTC timezone. I needed to do some logic on this date, but always wanted it in the users local timezone so
Solution 1:
I had figured out that it's the a
flag in the format string. I changed it to YYYY-MM-DDTHH:mm:ss
and it worked perfectly. Safari must not like am
/pm
data.
Solution 2:
follow this format. year should be at the beginning. have to use "/" instead of "-". cannot use "MMM" for month
YYYY/MM/DDhh:mmA
Solution 3:
Try wrapping up with String function
//strip submission date of timezone offsetlet submission_date = moment(String(this.state.startDate),'YYYY-MM-DD hh:mm:ss a');
let last_date = moment(String(this.last_date),'YYYY-MM-DD hh:mm:ss a').diff(submission_date, 'days');
Safari engine has some unique way of processing/parsing the date object
Post a Comment for "Why Is Iphone Ios Showing Invalid Date For Momentjs"