HTML input type date and time without timezone offset

后端 未结 2 2070
时光取名叫无心
时光取名叫无心 2021-02-13 20:05

I am using HTML5 input date and input time for ionic development. By default, it binds as ISO Date String and change to UTC date time. It seems wrong to me as when user choose t

2条回答
  •  Happy的楠姐
    2021-02-13 20:42

    First of all it is interesting that type="datetime" has been removed from the HTML5 standard and instead only "datetime-local" exists, yet it appears that not every mobile browser implements it. For type="date", it doesn't have a time component, so just use the UTC date directly. True, converting a UTC date d to local is kind of ridiculous:

    • new Date(d.toLocaleDateString())

    or

    • d.setMinutes(d.getMinutes()+d.getTimezoneOffset())

    or

    • new Date(+d+d.getTimezoneOffset()*60000)

    but what can you do?

提交回复
热议问题