PHP的日期和時間

來源:互聯網
上載者:User

標籤:

<?php//2.擷取日期和時間//時間是一維的,所以任何一個時間的時間戳記都是不一樣的//array getdate([int timestamp]);//string date(string format[,int timestamp])/*Y: 四位元年m: 月01-12 帶0n: 月1-12d: 天01-31 帶0j: 天1-31H: 24小時制h: 12小時制i: 分鐘00-59s: 秒00-59w: 星期幾0-6A: 上午AM或下午PMa: 上午am或下午pm修改預設時區方法一:修改設定檔 date.timezone = Etc/GMT+8方法二:date_default_timezone_set("PRC"); //設定中國時區       date_default_timezone_get(); //擷取當前時區*/echo time(); //輸出目前時間的時間戳記echo "<br />";//時分秒 月日年echo date("Y-m-d H:i:s", mktime(1, 30, 30, 5, 15, 2007));echo "<br />";echo strtotime("now"); //now表示當前的時間戳記,就是擷取參數對應的時間戳記echo "<br />";echo strtotime("+1 day");echo "<br />";echo date("Y-m-d H:i:s", strtotime("5-10-2014 12:30:30"));echo "<br />";$arr = getdate(); //其參數有哪些?返回現在時間的日期資訊數組echo "<pre>";print_r($arr);echo "</pre>";echo "<br />";echo date("Y-m-d H:i:s"); //格式化時間函數,不傳參數,表示格式化目前時間echo "<br />";echo microtime(); //返回當前的精確到毫秒數時間戳記echo microtime(true); //以浮點型的形式返回當前的時間戳記?>

 

PHP的日期和時間

聯繫我們

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