a date input where the user enters 2019-12-22
gives these values:
input.value
:"2019-12-22"
input.valueAsNumber
:1576972800000
input.valueAsDate
:"Sat Dec 21 2019 16:00:00 GMT-0800 (Pacific Standard Time)"
- this resulting date object just seems wrong
- when the browser returns a value, it treats the user input as universal time
- so the date object's utc representation is the same as what the input displays to the user
input.valueAsDate.getUTCDate()
returns22
, which is what the user enteredinput.valueAsDate.getDate()
returns21
, NOT what the user entered- thus we conclude the date input displays and accepts utc time, not local times
we want the resulting date.toString()
to show the same result as the original user input in the date-input
how can we allow users to interact with local times, but then obtain a correct date object in our scripts?