Closed vzsoft closed 11 months ago
i try use momentjs result not correct !
var date1 = moment("/Date(1696015674297+0330)/"); //DateTimeOffset json Result
//Result: Fri Sep 29 2023 22:57:54 GMT+0330 not correct
The serialized dates should be in UTC,.
You can find out how to parse WCF JSON dates in the JSON Format docs.
The Dates themselves are in UTC, it's up to you with how you want to handle the offsets.
Note: you've checked GitHub Username is registered on Support page, but I can't find a record for your GitHub Username, please ensure your GitHub username is listed as a registered support contact prior to opening issues.
JsonSerializer Automatic conversion of DateTime
to UTC for TimestampOffset
.
But it doesn't do this for DateTimeOffset
.
i try use Newtonsoft.Json work result correct
Newtonsoft.Json.JsonConvert.DefaultSettings = () => new Newtonsoft.Json.JsonSerializerSettings
{
DateFormatHandling= Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat,
};
//Date Now : 9/29/2023 7:27:54 PM +03:30
var newtonj = Newtonsoft.Json.JsonConvert.SerializeObject(DateTimeOffset.Now);
//json2 Result: Date(1696003074485+0330) result correct
...
This should be resolved in the latest v6.10.1+ that's now available in our pre-release packages.
Describe the issue
Hi,
I need convert
DateTimeOffset
andDateTime
to Json WithDateHandler.TimestampOffset
butDateTimeOffset
result not correct forDate
in javascriptReproduction
code in C#:
now i need convert result to
Date
in javascriptdate1 (
DateTimeOffset
json) result not correct 3:30 hours ahead date2 (DateTime
json) result correctExpected behavior
output json
DateTimeOffset
andDateTime
must be the same The only difference between them is thatDateTime
has no OffsetSystem Info
Additional context
sry my english not good
Validations