The exchange of date and timestamp under Linux

Source: Internet
Author: User
Tags timestamp to date

Http://www.linuxidc.com/Linux/2010-09/28537.htm

The exchange of date and timestamp under Linux

1. Date to timestamp:
$ Date-d ' 2009-12-01 23:20 ' +%s
1259680800
2. Timestamp to date
$ Date-d ' 1970-01-01 1259680800 sec UTC '
Tue Dec 1 23:20:00 CST 2009

3. Timestamp to UTC date
[[email protected] ~]# date-d ' 1970-01-01 UTC 1284117137 sec '-u
59 Month 11:12:17 UTC 2010

4. Date, the current time is converted to UTC timestamp
[Email protected] ~]# date +%s

1284117146

Gmt
GMT is an abbreviation for Greenwich Mean time, which is translated into "GMT" or "Greenwich Mean Time" in Chinese and translated into "Greenwich normal" or "GMT". Greenwich is located in Thames, R., south-east of London, and there is a Greenwich town in the United States, but it doesn't matter with time.

Utc
UTC is the abbreviation for coordinated Universal time, which translates to "Universal Time", or literal translation, to "coordinated general-purpose" or "coordinated World time". At present, it means GMT time. Why does it mean GMT time now? Because the Prime Meridian (Meridian is Meridian, the Prime meridian is the 0-degree meridian), it actually crosses the western mecca of Saudi Arabia, not Greenwich, England. At that time, the British Royal Society temporarily identified Greenwich as the prime meridian of the crossing point, and Britain is the prosperous period, the world is will wrong, used now. It is not possible to change one day to Mecca time for standard time. So we generally use UTC instead of GMT.

Pdt
PDT is an abbreviation for Pacific Daylight Time, which is translated into Chinese as "Pacific Daylight Savings Period", 7 hours later than UTC. Google has mentioned in its AdSense that "at 09-6-13, our engineers will maintain the site at PDT around 10:00 to 2:00." ”
In fact, in addition to PDT time, the North American region still has a lot of time:
The U.S. summer begins on the 1th Sunday of every April, ending on the last Sunday of every October. Daylight saving time is one hour earlier than normal, and the PDT time corresponds to PST, Pacific. PST After daylight saving time is over
Nst-newfoundland Standard Time Newfoundland
Ndt-newfoundland Daylight Time Newfoundland Daylight Time
Ast-atlantic Standard Time Atlantic
Adt-atlantic Daylight Time Atlantic Daylight Time
Est-eastern Standard Time EST
Edt-eastern Daylight Time Eastern Daylight Time
Cst-central Standard Time Central
Cdt-central Daylight Time Central daylight time
Mst-mountain Standard Time Mountain
Mdt-mountain Daylight Time Mountain daylight time
Pst-pacific Standard Time PST
Pdt-pacific Daylight Time Pacific daylight time
Akst-alaska Standard Time Alaska
Akdt-alaska Daylight Time Alaska daylight time
Hast-hawaii-aleutian Standard Time Hawaii-Aleutian
Hadt-hawaii-aleutian Daylight Time Hawaii-Aleutian Daylight Time
Pst
PST is the Pacific Standard Time (West VIII zone), with Beijing time (East eight district) jetlag-16 hours, that is, time of day minus 16 is PST. and PDT 1 hours earlier than PST, that is, PDT and Beijing time difference is-15 hours

Daylight saving time
Daylight saving time or daylight time.
The United States and Canada originally implemented winter time in the last Sunday of October each year, starting from 2 o'clock in the morning in April for the first Sunday, and resuming daylight savings.
But according to the latest energy bill passed by Congress, to strengthen daylight saving, the extension of daylight saving time since 2007, starting from the first Sunday of April every year, advance to the second Sunday in March, the end date from the last Sunday of the year October, postponed to the first Sunday in November. In other words, the winter time will be shortened by about one months. The arrangement was made in Sunday in order to facilitate the adjustment of life without being greatly affected.

Linux system changes the time zone command timeconfig
or Cp/usr/share/zoneinfo/america/los_angeles/etc/localtime.


2010 US Daylight Saving Time: US 2010 daylight hours will start 02:00 local date on March 14
Then the time server will automatically jump from 01:59:59 to 03:00:00

Linux under Modified time zone


The Linux clock is divided into the system clock and the hardware (Real time clock, or RTC) clock. The system clock is the clock in the current Linux kernel, and the hardware clock is a battery-powered clock on the motherboard that can be set in the BIOS. When Linux starts, the hardware clock reads the settings of the system clock, and the system clock is independent of the hardware.

All commands in Linux, including functions, are the system clock settings used. In Linux, the commands used for clock viewing and setting are mainly date, hwclock, and clock. Among them, clock and hwclock usage similar, but clock command in addition to support x86 hardware system, but also support the Alpha hardware system.
1. Date
View system time
# date
Setting the system time
# date--set= "07/07/06 10:19" (Month/day/year: minutes: seconds)
2, Hwclock/clock
Viewing hardware time
# Hwclock--show
# clock--show
Set Hardware time
# Hwclock--set--date= "07/07/06 10:19" (Month/day/year: minutes: seconds)
# clock--set--date= "07/07/06 10:19" (Month/day/year: minutes: seconds)
3. Synchronization of hardware time and system time
According to the foregoing, reboot the system, hardware time will read the system time, to achieve synchronization, but do not restart, you need to use the Hwclock or clock command to achieve synchronization.
The hardware clock is synchronized with the system clock:
# Hwclock--hctosys (HC stands for hardware time, SYS represents system time)
Or
# clock--hctosys
system clock and Hardware clock synchronization:
# Hwclock--SYSTOHC
Or
# clock--SYSTOHC
4, the time zone settings
# Tzselect

The exchange of date and timestamp under Linux

Related Article

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.