The Linux timestamp and the standard time of the mutual turn

Source: Internet
Author: User

In Linux systems, there are many occasions where timestamps are used to represent time, that is, the number of days or seconds from January 1, 1970 onwards. such as the password change date and expiration date in/etc/shadow, as well as the access log of the proxy server to record the access time and so on. Here are some methods of timestamp format and standard Time format conversion: 1. Display the current time in standard format and timestamp, respectively
[[Email protected] ~]# Date
August 10, 2010 Tuesday 03:39:21 CST
[Email protected] ~]# date +%s
2. Display time stamp of specified time
[Email protected] ~]# date-d "2010-07-20 10:25:30" +%s

3. Convert timestamp to Standard Time format Method 1: Use the date command
[Email protected] ~]# date-d "@1279592730"
July 20, 2010 Tuesday 10:25:30 CST
[[email protected] ~]# date-d "1970-01-01 UTC 1279592730 Seconds"
July 20, 2010 Tuesday 10:25:30 CST
[Email protected] ~]# date-d "1970-01-01 14781 Days" "+%y/%m/%d%h:%m:%s"
2010/06/21 00:00:00
[Email protected] tmp]# date-d "@1279592730"
Tue Jul 10:25:30 CST 2010
[Email protected] tmp]# date-d "@1279592730" + "%y%m%d%h:%m:%s"
20100720 10:25:30
[Email protected] tmp]# date-d "@1279592730" + "%F%h:%m:%s"
2010-07-20 10:25:30
[[email protected] tmp]# date-d "1970-01-01 UTC 1279592730 Seconds"
Tue Jul 10:25:30 CST 2010
[[email protected] tmp]# date-d "1970-01-01 UTC 1279592730 Seconds" + "%F%h:%m:%s" 2010-07-20 10:25:30
Method 2: Use the time function in awk
[[email protected] ~]# echo "1279592730" |awk ' {print strftime ("%F%T", $)} '
2010-07-20 10:25:30
Method 3: Use Perl to process
[Email protected] ~]# perl-e ' Print localtime (1279592730). " \ n ";"
Tue Jul 20 10:25:30 2010
Supplement: Explanation of the time format UTC (Universal time COORDINATED,UTC) world co-ordination period CST (Chinese standard Times utc+8:00) China coastal Time (Beijing time) GMT (Greenwich Mea N Time) GMT: System time zone setting:
[Email protected] ~]# vim/etc/sysconfig/clock zone= "Asia/shanghai"
[Email protected] ~]# Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime
--------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------
The Unix/linux timestamp is converted in Oracle Unix/linux Timestamp is a number of seconds calculated from the GMT January 1, 1970 period. Unix/linux timestamp converted to standard time format (mainly note time zone issues): Select To_date (' 19700101 ', ' yyyymmdd ') + 1235728935/86400 +to_number (SUBSTR (tz_ OFFSET (Sessiontimezone), 1,3))/24 from dual where 1235728935 is the unix/linux timestamp, after the conversion is expressed as 2009-2-27 18:02:15. In turn, the time zone is also considered: select (To_date (' 2009-2-27 18:02:15 ', ' yyyy-mm-dd hh24:mi:ss ')-to_date (' 1970-1-1 ', ' yyyy-mm-dd ') * 86400-to_number (SUBSTR (Tz_offset (Sessiontimezone), 1,3)) *3600 from dual
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.