DateTime transforms ISO time string without timezone into UTC
See original GitHub issueShort description of the problem:
When I use an <ion-datetime>
and set the initial value to an ISO time string without a timezone (e.g. 2016-07-03T15:30
), after changing the time the string now has a ‘Z’ at the end signifying UTC.
What behavior are you expecting?
It says in the Ionic docs:
Any of the ISO formats below can be used, and after a user selects a new value, Ionic will continue to use the same ISO format which datetime value was originally given as. … Date and Time | YYYY-MM-DDTHH:mm | 1994-12-15T13:47
I would expect, then, for my format (YYYY-MM-DDTHH:mm) to remain the same. Sorry if I have misunderstood this. If my issue is expected behavior, then I guess the docs should be updated.
Steps to reproduce:
- Initialize an
<ion-datetime>
with an ISO string without a timezone specified. - Change the date using the picker.
Which Ionic Version?
2.x
Plunker that shows an example of your issue
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
DateTime transforms ISO time string without timezone into UTC
Steps to reproduce: Initialize an <ion-datetime> with an ISO string without a timezone specified. Change the date using the picker.
Read more >Safari is parsing ISO 8601 date-time strings without timezone ...
In Safari these time strings are interpreted as UTC and then the string format converts it to local time. new Date("2020-05-06T13:25:00").
Read more >Create a Date without Timezone using JavaScript | bobbyhadz
To create a date without timezone, get the ISO representation of the date string. ... my time zone is 3 hours ahead of...
Read more >Convert ISO UTC date.time to Local timezone - ServiceNow
Solved: i have an ISO date 2020-09-15T04:52:16.833Z in a Script step in Action Designer, how can apply the system timezone to the value...
Read more >Demystifying DateTime Manipulation in JavaScript - Toptal
We will ignore the user's time zone and use UTC while creating the date object. There are two ways to do it: Create...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Mike, suggests that Ionic wouldn’t be handling this issue. Reference
Humbly tagging @adamdbradley @danbucholtz @mlynch to please have a relook at this issue.
So there’s no good cross-platform way to handle this. Each browser would do something different and it is very error prone.
A better way would be to use ngModel and a pipe
This will let you pass the value to something like momentJS or Date-fns as a pipe then update the value on change as well
http://plnkr.co/edit/MHjUdC