I Have this tick number 1448013624577
from a java site and im trying to convert to ac# DateTime
doing this
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(1448013624577 / 1000d);
But the hour of this tick are 2 hours after the hour of the DateTime
My time zone is (GMT-3) but right now I'm in daylight save (GMT-2)
How can I convert this tick with my time zone?
What about DateTime myDate = new DateTime(numberOfTicks);
?
See this answer .
I solved this issue using DateTimeOffset
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(1448013624577 / 1000d);
var dof = new DateTimeOffset(dt, new TimeSpan(0));
var dtGmt = dof.ToLocalTime().DateTime;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.