IOS Phone time Zone acquisition issues

Source: Internet
Author: User
Tags time zones time zone names

Time zone abbreviation UTC, CST, GMT, CEST and conversion

UTC is an abbreviation for Coordinated Universal Time (Universal time coordinated), which is defined and recommended by the International Radio Advisory Committee and is maintained by the International Time Bureau (BIH) in seconds-based scale. UTC is equivalent to the average sun on the Prime meridian (that is, longitude 0 degrees), which used to be expressed in Greenwich Mean Time (GMT). Beijing time is 8 hours earlier than UTC time, with January 1, 1999 0000UTC as an example, UTC time is 0 points and Beijing time is January 1, 1999 8 o'clock in the morning.

GMT (Greenwich Mean time) is Greenwich Normal:
Because the Earth's orbit is not circular, its operating speed changes with the distance between the Earth and the sun, so the sun is not uniform. The length of the solar day is also affected by the inclination of the earth's axis of rotation relative to the orbital surface. To correct the inhomogeneity above, astronomers calculate the effect of the Earth's non-circular trajectory and polar axis tilt on the sun. When the sun is flat, it refers to the revised view of the sun. When the sun is flat on the Greenwich meridian, it is called World Time (UT0), also known as Greenwich Mean (GMT). In order to ensure that the world is coordinated with the world Time (UT1) is not more than 0.9 seconds, if necessary, in the coordinated world time to add positive or negative leap seconds. As a result, there are several integer seconds differences between coordinated Universal time and International Atomic Time (TAI). The International Earth Rotation Service Central Bureau (IERS) in Paris is responsible for deciding when to join leap seconds.

In other words, UTC is basically equal to GMT

Cet

(English: Central European Time,cet) is one of the time zone names that are one hours earlier than world standard Time (UTC). It is used by most European countries and some North African countries. The winter time is utc+1, and the summer European daylight is utc+2.

CEST

One of the time zone names that are two hours earlier than the world Standard Time (UTC) in Central European Daylight savings period (European Summer, or CEST). It is used by most European countries and some North African countries in the summer (utc+2), in winter these countries use Central Europe time (UTC+1)

Time zone online conversion tool site http://www.timebie.com/timezone/centraleuropeansummerbeijing.php

Cst

CST can also represent the following 4 different time zones:

Central Standard Time (USA) utc-6:00

Central Standard Time (Australia) utc+9:30
China Standard Time utc+8:00
Cuba Standard Time utc-4:00
It can be seen that CST could also represent the standard time in four countries of the United States, Australia, China, and Cuba. In other words, this needs to determine which time zone is used based on the scenario used.

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

1. The standard way to get the time zone right

[Nstimezone Resetsystemtimezone]; Resetting the time zone of your phone system

Nsinteger offset = [Nstimezone localtimezone].secondsfromgmt;

offset = offset/3600;

NSString *tzstr = [NSString stringwithformat:@ "%ld", (long) offset];

 Time zone obtained: (Asia/shanghai (gmt+8) offset 28800)

2. Intercept GMT method

Get your local time zone

NSString *tzstr;

Nstimezone *localtimezone = [Nstimezone localtimezone];

Nsarray *zonearray = [[NSString stringwithformat:@ "%@", Localtimezone] componentsseparatedbystring:@ "GMT"];

NSString *TEMPTZ = [NSString stringwithformat:@ "%@", Zonearray.lastobject];

Eg: +8 remove "+",-8 incoming all, +0/-0

-1 ~ 12, 1 ~ +12, 0

if ([Temptz hasprefix:@ "+"]) {

TZSTR = [NSString stringwithformat:@ "%c", [Temptz Characteratindex:1]];

}else if ([Temptz hasprefix:@ "-"]) {

TZSTR = [NSString stringwithformat:@ "%@", [Temptz Substringtoindex:2]];

}else if ([Temptz hasprefix:@ "0"]) {

TZSTR = [NSString stringwithformat:@ "%@", [Temptz Substringtoindex:1]];

}

Get time zone: Europe/berlin (CEST) offset 7200 (daylight)

Given that some time zones do not carry the GMT format , "method Two" is not OK, using "Method one".

The time zone is calculated based on the number of seconds from 0 time zone deviations.  

IOS Phone time Zone acquisition issues

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.