C#模拟JS中的getTime()
//模拟JS中的Date.Gettime();
private long lLeft = 621355968000000000;//1970距0000的微秒数
//将数字变成时间
public string GetTimeFromInt(long ltime)
{
long Eticks = (long)(ltime * 10000000) + lLeft;
DateTime dt = new DateTime(Eticks).ToLocalTime();
return dt.ToString();
}
//将时间变成数字
public long GetIntFromTime(DateTime dt)
{
DateTime dt1 = dt.ToUniversalTime();
long Sticks = ((dt1.Ticks - lLeft)*100)/1000000;
return Sticks;
}
posted on 2012-09-10 20:58 Jason_liu 阅读(1063) 评论(0) 编辑 收藏 举报