In Linux systems, there are many occasions when a timestamp is used to represent the time, from January 1, 1970 to the current number of days or seconds. such as the/etc/shadow Password change date and expiration date, as well as the proxy server's access log to the access time records, and so on. Several timestamp formats and standard time format conversions are described below: 1, displaying the current time in standard formats and timestamps, respectively [Root@365linux ~]# Date August 10, 2010 Tuesday 03:39:21 CST 1281382775 2, display the time stamp of the specified time [Root@365linux ~]# date-d "2010-07-20 10:25:30" +%s 1279592730 3. Convert time stamp to standard time format Method 1: Use the date command July 20, 2010 Tuesday 10:25:30 CST July 20, 2010 Tuesday 10:25:30 CST 2010/06/21 00:00:00 [Root@localhost tmp]# Tue 10:25:30 CST 2010 [Root@localhost tmp]# date-d "@1279592730" + "%y%m%d%h:%m:%s" 20100720 10:25:30 [Root@localhost tmp]# 2010-07-20 10:25:30 [Root@localhost tmp]# Date-d "1970-01-01 UTC 1279592730 Seconds" Tue 10:25:30 CST 2010 [Root@localhost 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 2010-07-20 10:25:30 Method 3: Use Perl processing Tue 20 10:25:30 2010 Supplemental: Interpretation of the time format UTC (Universal Time COORDINATED,UTC) World Coordination Times CST (China Standard period utc+8:00) Chinese coastal Time (Beijing time) GMT (Greenwich Mea N Time GMT: System time Zone settings:[Root@365linux ~]# Vim/etc/sysconfig/clock
Utc=true Arc=false [Root@365linux ~]# Cp/usr/share/zoneinfo/asia/shanghai /etc/localtime --------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------- Oracle converts the Unix/linux timestamp unix/linux the timestamp is a number of seconds calculated from the GMT January 1, 1970 period. The Unix/linux timestamp is converted to a standard time format (mainly attention to time zone issues): Select To_date (' 19700101 ', ' yyyymmdd ') + 1235728935/86400 +to_number (SUBSTR OFFSET (Sessiontimezone), 1,3))/24 from dual 1235728935 is the unix/linux timestamp, which is then expressed as the 2009-2-27 18:02:15. Conversely, consider time zones: 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
Turn http://hi.baidu.com/taolizao/blog/item/2d6f9a1ba50ef3eae0fe0ba9.html |