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

How to realize time conversion operation in Linux

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

Share

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

This article will explain in detail how to achieve time conversion operation in Linux. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

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)

On how to achieve time conversion operations in Linux to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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