asp.net实现UNIX 时间戳

//1 将系统时间转换成UNIX时间戳
    DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));
    DateTime dtNow = DateTime.Parse(DateTime.Now.ToString());
    TimeSpan toNow = dtNow.Subtract(dtStart);
    string timeStamp = toNow.Ticks.ToString();
    timeStamp = timeStamp.Substring(0,timeStamp.Length - 7);
    Response.Write(timeStamp);
   
    //2将UNIX时间戳转换成系统时间   
    string timeStamp = this.txtDate.Text;
    DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1));
    long lTime = long.Parse(timeStamp + "0000000");
    TimeSpan toNow = new TimeSpan(lTime);
    DateTime dtResult = dtStart.Add(toNow);
    Response.Write(dtResult);

asp.net实现UNIX 时间戳,布布扣,bubuko.com

asp.net实现UNIX 时间戳

上一篇:php将xml文件转化为数组:simplexml_load_string


下一篇:asp.net文本编辑器FCKeditor使用方法详解