Category / Section
How to preserve UTC time for tasks' dates in Gantt
1 min read
While requesting a data source from different time zones, the time of input dates will be converted from server defined UTC time to the local machine’s time. By defining the DateTimeKind property to input dates, it is possible to prevent the time conversion from UTC to local machine’s time and display all the dates in server defined UTC format.
The following code example explains the above scenario.
list.Add(new DefaultData() { Id = 1, Name = "Parent Task 1", StartDate = new DateTime(2019,1,10,05,00,00,DateTimeKind.Utc), EndDate = new DateTime(2019,1,17,05,00,00,DateTimeKind.Utc), Duration = 5, PercentDone = 40 }
Using the above code, you can preserve the UTC for the dates and retrieve the date value from the server side.
You can also find a sample here for further reference.