php日期函數的簡單範例程式碼

來源:互聯網
上載者:User
  1. php日期函數的小例子-bbs.it-home.org
  2. echo time();//輸出從1970年1月1日0時0分0秒到目前時間的秒數(時間戳記)
  3. echo "
    ";
  4. echo mktime(23,56,59,12,20,1999);//輸出指定時間(時分秒月日年)的時間戳記
  5. echo mktime(23,56,59,13,20,1999);//時間超出,往下推算
  6. echo "
    #------------strtotime函數-----------------#
    ";
  7. echo strtotime("2009-10-12 20:20:29");//把指定的時間日期轉化為時間戳記,月日年的串連
  8. //只能用-或者/,時分秒的串連只能是:
  9. echo strtotime("2009/10/12 20/20/29");//無法輸出

  10. echo "
    #-------------getdate、date函數---------------#
    ";

  11. print_r(getdate());//返回目前時間戳下日期數組,預設為目前時間戳
  12. $arrtime=getdate(strtotime("2009-10-12 20:20:29"));//返回指定日期時間戳記的數組
  13. echo "
    ";
  14. echo $arrtime["minutes"];
  15. echo "
    ";
  16. echo date("Y‖m‖d H‖i‖s A");//輸入指定日期時間戳記的日期格式,預設為目前時間戳
  17. echo "
    ";
  18. echo date("Y年m月d日 H時i分s秒 A",strtotime("2009-10-12 20:20:29"));
  19. ?>
複製代碼

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.