C # in a row of code to implement 18-digit digital timestamps to DateTime

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

Share pictures

< 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

Share pictures

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));

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3067 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.