[linux]date command timestamp and time conversion

Source: Internet
Author: User
Tags string format

Many times we look at the data in the database, or the data in other people's systems need to be time-stamped to query, or the result of the query is a timestamp. There are times when you need to enter a timestamp for the query condition. My previous approach is to use the online tool to complete, and later with the Mac, I think directly with the command line to solve the good, do not have to open a browser every time the trouble (actually dozen command unfamiliar also trouble)

Here is the operation under the Mac, mainly with the date this command, more usage with the man command to view

string format time to timestamp

We know that the date command can directly convert the current time to a timestamp

# date +%s1436781527

And here we turn our defined time into timestamps.

# date "%Y-%m-%d %H:%M:%S""2015-07-13 18:02:00""+%s"1436781720

In fact this slightly complicated if hand hit

Time stamp to time

But the time stamp becomes readable time form is very simple, Mac and CentOS a little different

On Mac

date-r143678172020157月1318时02分00秒 CST

On CentOS

$ @14367817202015071318:02:00CST

These two commands are really short and good to remember

Copyright NOTICE: This article is Orangleliu (http://blog.csdn.net/orangleliu/) original article, the article reproduced please declare.

[linux]date command timestamp and time conversion

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.