ios incompatible javascript time new Date ( 'yyyy-mm-dd') solution

In mint-ui in the picker, time-dependent method will be used

<!--时间弹框-->
<mt-datetime-picker
        ref="picker"
        v-model="pickerVisible"
        type="datetime"
        year-format="{value} 年"
        month-format="{value} 月"
        date-format="{value} 日"
        :startDate="datePikerStartTime"
        @confirm="handleConfirm">
</mt-datetime-picker>

There is a time to start, we generally write the date object new Date()
whose value pickerVisible, is also a target time

  • Object is converted to the time when the year, month, day, hour , use getYear, getMonth () methodnew Date('2019-6-21 17:24').getMonth()
  • Object is converted to the time stamp, use getTime () methodnew Date().getTime()
  • Year, month, day, hour if you want to convert the time object to direct new Date ();new Date('2019-6-21 17:24')
In the mobile terminal, mobile phone ios found time error

Only to find, ios not support the new Date('xxxx-xx-xx')conversion time object failed

Solution 1:

new Date("2018-06-14 00:00:00".replace(/-/g,'/')).getTime()

Solution: The time format 2018-06-14, modified 2018/06/14, written as follows

new Date("2018-06-14 00:00:00".replace(/-/g,'/')).getTime()
//或者
new Date("2018/06/14 00:00:00").getTime()

Guess you like

Origin blog.csdn.net/qq_34664239/article/details/93208733