How do you parse a date from an HTML5 date input?

后端 未结 6 1086
攒了一身酷
攒了一身酷 2020-12-15 23:40

I have an input on my webpage that I am able to set the date on by getting an ISO string and pulling out the first 10 characters.

date = new Date();
dateInpu         


        
6条回答
  •  悲&欢浪女
    2020-12-15 23:58

    It's interpreting the date as UTC, which, for most time zones, will make it seem like "yesterday". One solution could be to add the time-zone offset back into the date to "convert" it to your local timezone.

提交回复
热议问题