About Time: UTC time, GMT time, local time, Unix timestamp

Source: Internet
Author: User
Tags local time

1.UTC Time and GMT time

We can think of GMT as time Coordination Time (GMT=UTC), GMT and UTC time are calculated in seconds.

2.UTC Time and Local

UTC + time Zone difference = local time

Time zone Chadong is positive, West is negative. Here, the East eight zone time zone is +0800,

UTC + (+0800) = local (Beijing) time (1)

So, UTC = local time (Beijing time))-0800 (2)

3.UTC and Unix Timestamp

The UTC time that you see in your computer is calculated from (January 01, 1970 0:00:00) to the number of seconds. The UTC time that you see is the number of seconds from the 1970 point of time to the exact time. The second number is the Unix timestamp.

4. How to determine whether the program gets the UTC time or the local time
Let the program get a timestamp first, and then change the system's time zone settings. Then rerun the program, obtaining a timestamp, comparing the difference of two timestamps if it is small (should be less than half an hour, or 180 seconds), then the UTC time is obtained because this time is not related to your system time zone settings.
Take the C language as an example:
void Main (void)
time_t start;
Time (&start);
printf ("%d\n", start);
while (1);


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.