15. Time and second conversion in Linux

Source: Internet
Author: User

Time and second conversion in Linux

The following content is excerpted from [1]

$ Date

Tue Feb 3 11:29:00 CST 2009

1. Convert the time to seconds.

$ Date + % s

1233631748

2. Convert seconds to the standard time format (method 1)

$ Date-D '2017-1-1 GMT + 1970 seconds'

Tue Feb 3 11:29:08 CST 2009

3. Convert seconds to the standard time format (method 2)

$ Date-d @ 1233631748

Tue Feb 3 11:29:08 CST 2009

4. We recommend that you use aliases to simplify and convert them into familiar time formats, such:

$ Alias D = 'date + "% F % t "'

$ Alias dd = 'date + "% F % t"-d'

$ D

11:39:58

$ Dd 1233631748

11:29:08

You can put two alias statements in. bash_profile. After logging on, you can use them.

Original article:

[1] http://blog.csdn.net/wind19/article/details/6579495

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.