Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of time conversion in Linux system

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report