DateTime to UnixTime Stamp in .net

后端 未结 4 1912
再見小時候
再見小時候 2020-12-10 06:54

Is there any function in vb dot net to convert datetime to unix time stamp If I google I get only the vice versa but not vb.net to unix time stamp

Any help is appre

4条回答
  •  渐次进展
    2020-12-10 07:29

    Looking at http://www.codeproject.com/KB/cs/timestamp.aspx it shows unix->.net so you can go backwards most likely:

    DateTime dt = "the date";
    DateTime start= new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
    
    TimeSpan ts = (dt - start);
    
    ts.TotalSeconds //unix timestamp
    

    or something similar will do it.

    note, this has not been tested by me so it probably wont work :)

提交回复
热议问题