简体   繁体   中英

Date Time to Seconds

C# code to convert date and time format to seconds . eg: 2013-04-03 01:00:00 to 1364950800

You appear to be looking for the Unix file time (ie since 1 Jan 1970):

var unixFileTimeOrigin = DateTime.Parse("1970-01-01");
var date = DateTime.Parse("2013-04-03 01:00:00");

Console.WriteLine((date - unixFileTimeOrigin).TotalSeconds);
>>> 1364950800

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM