Linux shell downconversion unix time
Linux shell downconversion unix time
Here is a little way to convert the Unix time display format under Shell, and give a solution to the students who are familiar with the date command immediately.
$date-d @ 1234567890
Sat Feb 14 07:31:30 CST 2009
But what if the date version is too low to support the @ parameter? Let's try the-d parameter
$date-d "UTC 1970-01-01 1234567890 secs"
Sat Feb 14 07:31:30 CST 2009
If you think you can't remember a long string of characters at a time, write a small function yourself, which you can call in ~ / .bashrc.
# convert Unix time to local time string
Function ctime ()
{
Date-d "UTC 1970-01-01 $1 secs"
}
How to use it is simple:
$ctime 1234567890
Sat Feb 14 07:31:30 CST 2009
[this article was first posted in: Baidu Operation and maintenance Space] http://hi.baidu.com/ops_bd/blog/item/a3cca26712209058eaf8f87b.html
[pay attention to Baidu Technology Salon]