C# Unix Timestamp to DateTime -
i appreciate question has been covered many times on in various forms, none seem particular problem i'm experiencing. have following method use convert incoming data c# datetime variable. trouble is, company sending data in claiming i'm converting incorrectly because times appearing 1 hour behind in system. assume british summertime, problem @ end, or @ end, because thought method below taking account of british summertime fact i'm using tolocaltime? gratefully accepted.
private datetime converttimestamp(double t) { return new datetime(1970, 1, 1, 0, 0, 0, 0, datetimekind.utc) .addmilliseconds(t) .tolocaltime(); }
tolocaltime adjust timezone whatever local time of computer running method. depending on it's run from/deployed in cloud can give wildly different results. timezones can huge pain in butt kind of stuff. ideal if send utc unix representation , unwrap datetime touniversal , from there can safely convert timezone of choosing.
if they're not sending utc need find out timezone they're expecting , use instead of tolocal.
Comments
Post a Comment