Convert Time to UNIX Time in C#
2005-03-27 22:46
513 查看
I needed to convert now (datetime) to UNIX Time (number of seconds or milliseconds since jan 1, 1970) using C#.
I was able to use this little code to do the conversion.
DateTime dt70 = new DateTime( 1970, 1, 1, 0, 0, 0, 0 );
long ticks1970 = dt70.Ticks;
int gmt = (int) ((DateTime.UtcNow.Ticks - ticks1970 ) / 10000000L);
I was able to use this little code to do the conversion.
DateTime dt70 = new DateTime( 1970, 1, 1, 0, 0, 0, 0 );
long ticks1970 = dt70.Ticks;
int gmt = (int) ((DateTime.UtcNow.Ticks - ticks1970 ) / 10000000L);
相关文章推荐
- How to Convert a Date Time to “X minutes ago” in C# z
- Convert objects to JSON in C# using JavaScriptSerializer
- How can I convert String to Int in C#?
- mysql c# Unable to convert MySQL date/time value to System.DateTime 错误
- Convert string to binary and binary to string in C#
- convert utc time to local time in excel
- Simple trick to convert Date format with timezone in Java!
- How do I convert an enum to a list in C#?
- convert from dd/mm/yyyy to mm/dd/yyyy in c#
- How do I convert an enum to a list in C#?
- Convert PGM to BMP in C#
- How to convert XML to JSON in ASP.NET C#
- [D3] Convert Dates to Numeric Values with Time Scales in D3 v4
- Convert objects to JSON in C# using JavaScriptSerializer
- CareerCup Convert a BST to max heap without using extra memory and in as optimum time as possible
- How to convert XML to JSON in ASP.NET C#
- Convert object to json and json to object in C#
- How to convert an IPv4 address into a integer in C#?
- Convert objects to JSON in C# using JavaScriptSerializer
- Convert a string to a byte array and vica-versa in C#