开发者

Convert DateTime to ticks in .NET?

开发者 https://www.devze.com 2022-12-31 02:34 出处:网络
How to convert one DateTime开发者_高级运维 to ticks? By using the Ticks property: DateTime now = DateTime.Now;

How to convert one DateTime开发者_高级运维 to ticks?


By using the Ticks property:

DateTime now = DateTime.Now;
long ticks = now.Ticks;


static long ConvertDateTimeToTicks(DateTime datetime)
    {
       long  ticks=datetime.Ticks;
       return ticks;
    } 

  static DateTime ConvertTicksToDateTime(long ticks)
    {
       DateTime datetime= new DateTime(ticks);
       return datetime;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消