zoukankan      html  css  js  c++  java
  • asp.net时间戳与系统时间互转 mssql

        //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);
  • 相关阅读:
    ant design pro梳理
    JSON.stringify()
    数组小细节
    js this细节
    策略模式解决if-else过多
    使用useState的赋值函数异步更新问题
    Hook
    React Api
    Intent
    树的非递归遍历
  • 原文地址:https://www.cnblogs.com/craig/p/1723187.html
Copyright © 2011-2022 走看看