For example 1297380023295
should be 2010/2/11 9 AM I use this code right now
long dateNumber = num; long beginTicks = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks; DateTime dateValue = new DateTime(beginTicks + dateNumber * 10000); return dateValue;
The result of this function is 1 AM,It is GMT. What can I do with it?
DateTime currentTime = TimeZoneInfo. ConvertTime(DateTime. Now, TimeZoneInfo. FindSystemTimeZoneById("Central Standard Time"));
DateTime itself contains no real timezone information.
You're looking for the ToLocalTime()
method:
long unixDate = 1297380023295; DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); DateTime date= start.AddMilliseconds(unixDate).ToLocalTime();
long a= 634792557112051692; //a= ticks time DateTime dt = new DateTime(a); Response.Write(dt.Hour.ToString()); //dt.hour convert time ticks to time hour
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With