There was a textbox1 and TextBox2 and a button
Require TextBox1 to enter the number of milliseconds after. Press Button TextBox2 Show time
such as textbox1 input 1248671343262 Press button after TextBox2 display similar to Mon June 13:09:03 CST 2009 such time
The number of milliseconds you call 1248671343262 is the Windows file time (a 64-bit value) that converts a DateTime object through a method TOFILETIMEUTC or Tofiletime, which represents the self Coordinated Universal Time (UTC) A.D. (C.E.) 1601 The number of intervals that have elapsed since 12:00 midnight, January 1, at a distance of 100 nanoseconds. Windows uses file time to record when an application creates, accesses, or writes files.
First convert it backwards to a DateTime object:
DateTime dt = DATETIME.FROMFILETIMEUTC (1248671343262);
You can also convert first to long ticks (the scale is 100 nanoseconds),
Long ticks = 1248671343262/100;
DateTime dt = new DateTime (ticks);
Then convert by format:
Dt.getdatetimeformats (' R ') [0].tostring ();
Tue, 1601 10:41:07 GMT
Then look at the difference between GMT and CST and make some adjustments.
See below for Unix timestamps and C # datetime type swaps
<summary>
method in converting a UNIX timestamp to a regular
System.DateTime value (and also to)
</summary>
<param name= "timestamp" >value to be converted</param>
<returns>converted datetime in String format</returns>
private static DateTime Converttimestamp (double timestamp)
{
Create a new datetime value based on the Unix epoch
DateTime converted = new DateTime (1970, 1, 1, 0, 0, 0, 0);
Add the timestamp to the value
DateTime newdatetime = converted.addseconds (timestamp);
Return the value in string format
return Newdatetime.tolocaltime ();
}
<summary>
method in converting a System.DateTime value to a UNIX timestamp
</summary>
<param name= "value" >date to Convert</param>
<returns></returns>
Private double Converttotimestamp (datetime value)
{
Create timespan by subtracting the value provided from
The Unix Epoch
TimeSpan span = (value-new datetime (1970, 1, 1, 0, 0, 0, 0). ToLocalTime ());
Return to total seconds (which is a UNIX timestamp)
Return (double) span.totalseconds;
}