The method of time conversion in Linux system
This article introduces the relevant knowledge of "time conversion method in Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Linux time conversion method:
(1) date-d "Wednesday, 17 December 2008 17:27:22 CST" + "s"
This order converts the CST at 17:27:22 on Wednesday, 17 December 2008 into a timestamp
Results: 1229515680
(2) convert the timestamp 1123495443 to an identifiable year, month, day, minute and second
Date-d '1970-01-01 UTC 1123495443 seconds'
Result: 18:04:03 CST on Monday, August 8, 2005
(3) date-d "Mon Jul 17 13:36:28 CST 2006" + "F% H:%M:%S"
This command converts the converted time "Mon Jul 17 13:36:28 CST 2006" to the format you want to output + "% F% H:%M:%S"
Result: 2006-07-17 13:36:28
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
Results: 1229507736
(2) convert the timestamp 1229507736 to the 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"
This command converts the converted time "`date`" to the format "+% s" you want.
Result: 2006-07-17 13:16:11
Add:
Under perl:
Convert timestamp to time perl-e "print scalar localtime '1209391893'"
Under PHP:
Timestamp generation method: mktime (hours, minutes, seconds, month, day, year)
Whether the Linux time conversion method is understood here.
This is the end of the content of "time conversion method in Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!