sWhy is iPhone IOS showing invalid date for momentjs

前端 未结 3 1333
独厮守ぢ
独厮守ぢ 2021-01-28 19:59

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

3条回答
  •  独厮守ぢ
    2021-01-28 20:21

    Try wrapping up with String function

    //strip submission date of timezone offset
    let 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

提交回复
热议问题