Closed Neilski closed 9 years ago
'2015-05-18T23:00:00.000Z'
is in ISO format.
The timezone is always zero UTC offset, as denoted by the suffix "Z"
To get locale time, try:
<p>Date: {{ startDate.toLocaleString() }}</p>
or use the date filter in Angular:
<p>Date: {{ startDate | date:'fullDate' }}</p>
Thank you for the explanation, but I am still slightly confused... The date in question is being supplied from an HTTP GET request from the server. The date supplied by the server is '2015-05-15T00:00:00' and it is this date that initially gets bound and displayed in the view, in my case 15/5/2015. When the data gets POSTed back it gets changed to '2015-05-14T23:00:00Z' i.e. the displayed date -1 hour. It is this conversion from displayed date to bound date that is confusing me. In this scenario, is it expected that the server should always store the date with a zero UTC offset and then convert to to locale time to service the request or store in local time and convert the response?
Sorry, I suspect this is a more general question than it should be.
Please ignore my last message. It seems that AngularJS's $http.post() method is responsible from the conversion from local date (UTC+ 1) to UTC+0. I will investigate further - thank you for your help.
I have a simple date only field using the UK data format dd/MM/yyyy as follows:
If I then add a bound value to the page:
and set the input to '19/5/2015' the reflected value changes to '2015-05-18T23:00:00.000Z' which is one hour behind where I would have expected it to be.
I am not sure if this issue is related to daylight savings (we are currently running British Summer Time GMT+1)?