Linux Time Conversion method

Source: Internet
Author: User

Linux Time conversion methods:

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

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

Results: 1229515680

(2) Convert time stamp 1123495443 to recognizable date

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

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

(3) date-d "Mon June 13:36:28 CST 2006" + "%F%h:%m:%s"

The command will be converted at the time "Mon June 13:36:28 CST 2006" to convert to the format you want to output + "%F%h:%m:%s"

Results: 2006-07-17 13:36:28

FreeBSD Time Conversion Method:

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

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

Results: 1229507736

(2) Convert timestamp 1229507736 to current time

Date-r 1229507736

Results: Wed Dec 17:55:36 CST 2008

(3) Date-j-F "%a%b%d%T%Z%Y" "Mon June-June 13:16:11 JST 2006" "+%f%h:%m:%s"

The command converts the converted time "' Date '" to the format you want "+%s"

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

Add:

Under Perl:

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

PHP under:

Generate Timestamp Method: Mktime (hours, minutes, seconds, months, days, years)

Do you understand the Linux time conversion method here?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.