Get time stamp in C #

Source: Internet
Author: User

  1. { Note: The following is a 13-bit in milliseconds   UTC   Timestamp (informal) }
    // The current UTC time is first obtained and then converted to the number of cycles (the number of ticks) for the calculation, with each period being 100 banknotes (NS) =0.1 microseconds (US) =0.0001 milliseconds (ms)
    //< Span style= "COLOR: #008000" >new a time of January 1, 1970, then converted to UTC time, converted to the number of ticks, and finally calculates the period difference between two times, because each cycle is 100 nanoseconds
    // to be converted to milliseconds divided by 10000 or multiplied by 0.0001
     long  times = (DateTime.UtcNow.Ticks-(new  DateTime (1970 , 1 ," Span style= "COLOR: #800080" >1 )). ToUniversalTime (). Ticks)/10000 ; 
  2. { Note: The following is a 10-bit local timestamp in seconds }
    This is also a 13-bit timestamp in milliseconds, and the difference above is that it is a local timestamp // and a 8-hour time difference with a UTC timestamp, usually with local timestamp, which is the following one.
    long times1 = (long) (DateTime.Now-(new DateTime (197011 ))). TotalSeconds;

Get time stamp in C #

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.