Conversion of time stamp format and standard time format under Linux

Source: Internet
Author: User

Everyone knows that every file in the Linux file system has three timestamps:

Access time (atime--access time): Is the date the file was last accessed.

Change Time (Ctime--change): Is the time of the file's inode change (what is the inode?). When you add data or delete data to a file, when you change the file owner, the CTime of the file changes when the link changes.

Modified (mtime--modification time): Is the time when the content of the file was last changed.

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 time stamp, respectively

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/5D/wKiom1c-qiXzriniAAAmCha_pWQ677.png "title=" capture. PNG "alt=" Wkiom1c-qixzriniaaamcha_pwq677.png "/>

2. Display time stamp of specified time

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/5D/wKiom1c-qo2DkSO8AAAd-e9axs0954.png "title=" 2.PNG " alt= "Wkiom1c-qo2dkso8aaad-e9axs0954.png"/>

3. Convert timestamp to Standard time format

Method 1: Use the date command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/5B/wKioL1c-rJzyXuIUAAAnZDjAwzs676.png "title=" 3.PNG " alt= "Wkiol1c-rjzyxuiuaaanzdjawzs676.png"/>

Method 2: Use the time function in awk

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/5D/wKiom1c-rJKhEpy6AAAl8vIFJRQ064.png "title=" 4.PNG " alt= "Wkiom1c-rjkhepy6aaal8vifjrq064.png"/>

Method 3: Use Perl to process

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/5B/wKioL1c-rq_zokt6AAAn_0o02CI629.png "title=" 5.PNG " alt= "Wkiol1c-rq_zokt6aaan_0o02ci629.png"/>

Add:

About the interpretation of the time format

UTC (Universal time COORDINATED,UTC) world coordination Times

CST China Time utc+8:00 (Beijing time)

GMT (Greenwich Mean Time) GMT:

System Time zone settings:

[Email protected] ~]# vim/etc/sysconfig/clock zone= "Asia/shanghai" utc=true arc=false [[email protected] ~ ]# Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime

############################################################################

Convert Unix/linux timestamps in Oracle

The 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 from Dual, 1235728935 of which is unix/linux time stamp, after 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


Conversion of time stamp format and standard time format under Linux

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.