Linux時間轉化方法

來源:互聯網
上載者:User

   Linux時間轉化方法:

  (1)date -d"2008年 12月 17日 星期三 17:27:22 CST" +"%s"

  該命令將2008年 12月 17日 星期三 17:27:22 CST轉化為時間戳記

  結果:1229515680

  (2)將時間戳記1123495443 換算成可以識別的年月日分秒

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

  結果:2005年 08月 08日 星期一 18:04:03 CST

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

  該命令將被轉換的時間“Mon Jul 17 13:36:28 CST 2006” 轉換為你想要輸出的格式+"%F %H:%M:%S"

  結果:2006-07-17 13:36:28

  Freebsd時間轉化方法:

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

  該命令將時間Wed Dec 17 17:55:36 CST 2008轉換為時間戳記

  結果:1229507736

  (2)將時間戳記1229507736轉換為目前時間

  date -r 1229507736

  結果: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"

  該命令將被轉換的時間"`date`" 轉換為你想要的格式"+%s"

  結果:2006-07-17 13:16:11

  補充:

  perl下:

  將時間戳記轉換為時間perl -e "print scalar localtime '1209391893'"

  PHP下:

  產生時間戳記方法:mktime(小時,分,秒,月,日,年)

  這裡是否弄明白了Linux時間轉化方法。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.