开发者

Convert DateTime to ticks in .NET?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜