HTML input type date and time without timezone offset

后端 未结 2 2061
时光取名叫无心
时光取名叫无心 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条回答
  •  孤街浪徒
    2021-02-13 20:24

    Javascript dates are always UTC, but you can get the local values as well as shown here: http://www.w3schools.com/jsref/jsref_obj_date.asp

    getUTCHours() Returns the hour, according to universal time (from 0-23) getHours() Returns the hour (from 0-23)

    The first one will always be translated to UTC from what was inputed. The second one will use the timezone offset to calculate what should be returned.

提交回复
热议问题