Linux time conversion method

  

Linux time conversion method:

(1)date -d"Wednesday, December 17, 2008 17:27:22 CST" +"%s"

This command converts 17:27:22 CST on Wednesday, December 17, 2008 into a timestamp

Result: 1229515680

(2) Converts the timestamp 1123495443 into an identifiable year Months, minutes and seconds

date -d '1970-01-01 UTC 1123495443 seconds'

Result: Monday, August 08, 2005 18:04:03 CST

(3)date -d"Mon Jul 17 13:36:28 CST 2006" +"%F %H:%M:%S"

The time the command will be converted “Mon Jul 17 13:36:28 CST 2006” Convert to the format you want to output +"%F %H:%M:%S"

Result:2006-07-17 13:36:28< Br>

Freebsd time conversion method:

(1)date -j -f "%a %b %d %T %Z %Y" "Wed Dec 17 17:55:36 CST 2008" "+%s"

This command converts the time Wed Dec 17 17:55:36 CST 2008 to a timestamp

Result: 1229507736

(2) Convert timestamp 1229507736 to current time

date -r 1229507736

Result: Wed Dec 17 17:55:36 CST 2008

(3)date - j -f "%a %b %d %T %Z %Y" "Mon Jul 17 13:16:11 JST 2006" "+%F %H:%M:%S"

The command converts the converted time "`date`" to the format you want"+%s"

Result:2006-07-17 13:16:11

Supplement:

Perl:

Convert timestamp to time perl -e "print scalar localtime '1209391893'"

PHP
下下:

Generate timestamp method: mktime (hour, minute, second, month, day, year)

Is there a way to understand Linux time conversion?

Copyright © Windows knowledge All Rights Reserved