zoukankan      html  css  js  c++  java
  • ASP.NET HttpContext的时间戳属性

    在ASP.NET框架,每一个HTTP请求到运行时将自动存储的时间戳。您可以通过timestamp属性,获得内容为一个DateTime支持字段DateTime值。在这里,我描述的HttpContext timestamp属性,并阐述它的一些细节。timestamp属性不读当前时间,它只能读取一个DateTime字段,在每个HTTP请求后自动存储的。因此,使用时间戳属性是速度远远超过使用DateTime.Now或以任何其他方式计算的时间。存储的时间戳属性的HttpContext类型的一个实例,是一个可以快速的方式得到一个请求到你的网站的启动时间。而不是访问的系统时钟,它会返回一个已经自动存储的DateTime值,这意味只是将几个字节复制到内存中,而不是任何时钟操作。因此,对于许多要求,时间戳属性的时间为导向的请求处理的理想选择。

           // 具体时间:
            Response.Write(Context.Timestamp.ToString() + "<br>");
            
    //年月日:
            Response.Write(Context.Timestamp.Date.ToString("D"+ "<br>");
            
    //年份:
            Response.Write(Context.Timestamp.Year+ "<br>");
            
    //月份:
           Response.Write( Context.Timestamp.Month+ "<br>");
            
    //日期部分:
            Response.Write(Context.Timestamp.Date+ "<br>");
            
    //日期号:
           Response.Write( Context.Timestamp.Day+ "<br>");
            
    //星期:
           Response.Write( Context.Timestamp.DayOfWeek+ "<br>");
            
    //一年中的第几天:
           Response.Write( Context.Timestamp.DayOfYear+ "<br>");
            
    //小時:
           Response.Write( Context.Timestamp.Hour+ "<br>");
            
    //毫秒:
           Response.Write( Context.Timestamp.Millisecond+ "<br>");
            
    //分:
           Response.Write( Context.Timestamp.Minute+ "<br>");
            
    //秒:
           Response.Write(Context.Timestamp.Second + "<br>");

    Ps:其实就是操作DateTime类型。

     

  • 相关阅读:
    (转)用Ajax技术让IE Web Control Tree View实现大数据量读取
    您试图从目录中执行CGI、ISAPI 或其他可执行程序,但该目录不允许执行程序
    oracle数据库中ORA28000: the account is locked问题
    C#动态生成html页面
    oracle 用户权限解释
    HCPC2013校赛训练赛 2
    ZOJ2770 Burn the Linked Camp 差分约束
    POJ2570 Fiber Network 状态压缩+floyd
    ZOJ3088 Easter Holidays 最短路
    POJ1364 King 差分约束
  • 原文地址:https://www.cnblogs.com/gengaixue/p/2121690.html
Copyright © 2011-2022 走看看