I have 3 date fields on a form view. The code on server side looks like this:
DateTime dtUTC = new DateTime(2010,8,8,2,4,6).SetKind(DateTimeKind.Utc);
DateTime dtLocal = new DateTime(2010,8,8,2,4,6).SetKind(DateTimeKind.Local);
DateTime dtUnspec = new DateTime(2010,8,8,2,4,6).SetKind(DateTimeKind.Unspecified);
One is in UTC,one in Local and and one is Unspecified. I am using JSON.NET to serialize the dates in ISO 8601 format. They get serialized correctly to client side and look as follows:
"UtcDate": "2010-08-08T02:04:06.0000000Z",
"LocalDate": "2010-08-08T02:04:06.0000000+05:30",
"TokyoDate": "2010-08-08T02:04:06.0000000"
Now I have 3 ExtJs(Version 6.0.1.250) date fields(I have set the 'displayFormat' to "yyyy'-'MM'-'dd HH':'mm':'ss" to display time as well) which displays them in the browser specific timezone format which is fine.
UTC Date: 2010-08-08 02:04:06
Local Date: 2010-08-08 07:34:06
Unspecified Date: 2010-08-08 02:04:06
My model fields are defined like this
{
name: "UtcDate",
type: "date",
allowNull: true,
dateFormat: "c"
},
{
name: "LocalDate",
type: "date",
allowNull: true,
dateFormat: "c"
},
{
name: "UnspecDate",
type: "date",
allowNull: true,
dateFormat: "c"
}
The problem is when I submit the date to server, I get the dates all in local time zone format
"UtcDate":"2010-08-08T07:34:06+05:30",
"LocalDate":"2010-08-08T02:04:06+05:30",
"UnspecDate":"2010-08-08T02:04:06+05:30"
Is there a way, I can get them back in the same time zone format as the server sent to client? Why does date field does not retain the original record time zone information while submitting?