I am creating a task in react frontend and it has some date fields. when I created a task I see the post call and the date fields showing in the post call as 2024-08-12T18:30:00.000Z
now I am opening the task which is a get call and in the response I am only seeing 2024-08-12T18:30:00
.
In the backend C# I am using
public DateTime? DateNow { get; set; }
I am missing the timezone “Z” in my GetCall, which I am seeing in my PostCall while creating the task.
How can I save the timeZone?
7
In case this helps…
If what you see is via the ToString("o")
keyword, make sure your DateTime object is set to DateTimeKind.Utc
as well; as the DateTime object’s kind may be Unspecified
var unspecified = new DateTime(2016, 12, 12, 10, 10, 10);
var specified = new DateTime(2016, 12, 12, 10, 10, 10, DateTimeKind.Utc);
Console.WriteLine (unspecified.ToString("o")); // 2016-12-12T10:10:10.0000000
Console.WriteLine (specified.ToString("o")); // 2016-12-12T10:10:10.0000000Z
Standard date and time format strings
3