Original text: A line of code in C# realizes the conversion of 18-digit digital timestamp to DateTime
Scene
The time stamp data accessed is:
636728674347302002
< p>
How to convert it to DateTime time.
Most of the current strategies are to convert to string, and then
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + < span style="color: #800000;">"0000000" );
TimeSpan toNow = new TimeSpan(lTime);
dateTimeStart.Add(toNow);
I tried it, and in Parse, it prompts that int64 is too large or too small.
Implement
DateTime dtStart2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime (timeStamp));
Effects
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + < span style="color: #800000;">"0000000" );
TimeSpan toNow = new TimeSpan(lTime);
dateTimeStart.Add(toNow);
DateTime dtStart2 = TimeZone.CurrentTimeZone.ToLocalTime( new DateTime(timeStamp));