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 I did the following:
//strip submission date of timezone offset
let submission_date = moment(this.state.startDate).format('YYYY-MM-DD hh:mm:ss a');
submission_date = moment(submission_date);
let last_date = this.last_date.diff(submission_date, 'days');
However, when I do this my iPhone complains that submission_date
is not a valid date. Desktop is fine so I'm guessing this is a safari issue. When I inspect this.state.startDate
just prior to being momentized it's a string like 2018-11-01T17:52:44-00:00
Shouldn't moment accept that as a valid date?
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.