Convert between Linux command date date time and Unix timestamp

A. Convert date to Unix timestamp Express
the current time as a Unix timestamp:

  1. date +%s

The output is as follows:

1361542433

Convert the specified date to a Unix timestamp:

  1. date -'2013-2-22 22:14'+%s 

The output is as follows:

1361542440

B. Convert a Unix timestamp to a datetime
format that does not specify a datetime:

  1. date -@1361542596

The output is as follows:

FriFeb2222:16:36 CST 2013   

Conversion of the specified date format:

  1. date -@1361542596+"%Y-%m-%d %H:%M:%S" 

The output is as follows:

2013-02-2222:16:36 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324822417&siteId=291194637