Timestamp attribute of ASP. NET httpcontext

Source: Internet
Author: User

In the ASP. NET Framework, each HTTP request will automatically store the timestamp at runtime.You can useTimestampAttribute to obtain the datetime value of a datetime supported field.Here, I describe the httpcontext timestamp attribute and describe its details. The timestamp attribute does not read the current time. It can only read one datetime field and is automatically stored after each HTTP request.Therefore, using the timestamp attribute is much faster than using datetime. Now or any other method. An instance of the httpcontext type storing the timestamp attribute can quickly get the start time of a request to your website.Instead of accessing the system clock, it will return a automatically stored datetime value, which means only several bytes are copied to the memory, rather than any clock operation. Therefore,It is ideal for processing time-oriented requests with many requirements and timestamp attributes.

// Specific time:
Response. Write (context. timestamp. tostring () +   " <Br> " );
// Year, month, and day:
Response. Write (context. timestamp. Date. tostring ( " D " ) +   " <Br> " );
// Year:
Response. Write (context. timestamp. Year +   " <Br> " );
// Month:
Response. Write (context. timestamp. Month +   " <Br> " );
// Date:
Response. Write (context. timestamp. Date +   " <Br> " );
// Date:
Response. Write (context. timestamp. Day +   " <Br> " );
// Week:
Response. Write (context. timestamp. dayofweek +   " <Br> " );
// The day of the year:
Response. Write (context. timestamp. dayofyear +   " <Br> " );
// Hours:
Response. Write (context. timestamp. Hour +   " <Br> " );
// Millisecond:
Response. Write (context. timestamp. millisecond +   " <Br> " );
// Points:
Response. Write (context. timestamp. Minute +   " <Br> " );
// Seconds:
Response. Write (context. timestamp. Second +   " <Br> " );

PS: Actually, it is the datetime type.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.