Last post Jun 16, 2017 09:45 AM by EvenMa
Jun 15, 2017 09:18 AM|StudentRik|LINK
I am working on an angular/ionic app and using webapi.
The app uses the "input type=date" to open the calendar on the device to select the date, the date when I create a new Date().toJSON() = 2017-06-15T08:59:46.998Z
but when I create a date from the calendar pop up it has the correct date in the input 15/06/2017 but behind the scenes it has made the date = 2017-06-14T23:00:00.000Z which always sets it a day behind due to the (GMT time difference) I am (+1.00 BST), When
I save this to the database through webapi is there a way to adjust the time so it has the correct day.
In my public static class WebApiConfig I have these settings
var jsonFormatter = formatters.JsonFormatter;
var settings = jsonFormatter.SerializerSettings;
settings.Formatting = Formatting.Indented;
settings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
settings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
When I get the data from the api with the wrong date, it displays the correct date as the device must do some conversion.
Is there a way to make the date correct when the device sends the data through the webapi?
Jun 16, 2017 09:45 AM|EvenMa|LINK
According to your description, you could set DateTimeZoneHandling by the following code:
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateTimeZoneHandling = DateTimeZoneHandling.Unspecified,
If you have any other questions, please feel free to contact me any time.