zoukankan      html  css  js  c++  java
  • c# 当前时间与数字互相转换

    1,1900年1月1日

    DateTime oldtime = Convert.ToDateTime("1900-1-1 00:00:00");//构造1900年1月1日
    TimeSpan ts
    = DateTime.Now.Subtract(oldtime);//计算从1900年1月1日到现在的时间间隔
    double num = ts.TotalSeconds;//计算出此间隔的总的秒数
    Response.Write(num
    +"<br/>");
    DateTime numtodate = oldtime.AddSeconds(num);//在1900年1月1日基础上添加这个秒数,还原成时间
    Response.Write(numtodate.ToString());


    2,0000年1月1日

     

    DateTime time = new DateTime(2005,12,5);
            Response.Write("ticks:" + time.Ticks+"<br/>");
            Response.Write("time:"+new DateTime(time.Ticks));

    DateTime time = new DateTime(2005,12,5);  //构造2005年12月5日的时间类型

    Response.Write("ticks:" + time.Ticks+"<br/>"); //time.Ticks为0000年1月1日到2005年12月5日的long类型数值,单位为100豪微秒

     Response.Write("time:"+new DateTime(time.Ticks));//new DateTime(time.Ticks)由long类型数值还原为时间类型

  • 相关阅读:
    (图论)树的直径
    HDU 4607
    类属性的增删改查
    python内置常用模块
    字典的使用
    元组的使用
    列表的基本函数
    字符串练习题
    python3.7字符串基本函数
    python简单的while语句和if语句的练习
  • 原文地址:https://www.cnblogs.com/zmxmiss/p/1719428.html
Copyright © 2011-2022 走看看