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;
}
精彩评论