您的位置:首页 > 编程语言 > C#

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); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: