PHP 時間和日期

來源:互聯網
上載者:User
<?php    header("Content-type: text/html; charset=utf-8");     date_default_timezone_set("PRC");    //PHP提供了內建函數time()來取得伺服器目前時間的時間戳記。    $curtime = time();    echo $curtime;    echo "<hr/>";     //date() 函數用于格式化時間,返回一個字串    $date= date("Y-m-d H:i",$curtime);    echo $date;    echo "<hr/>";     //mktime() 函數用於從日期取得時間戳記,成功返回時間戳記,否則返回 FALSE     // mktime(時, 分, 秒, 月, 日, 年)    $mktime = mktime("21","50","18","12","30","2015");    echo $mktime;    echo "<hr/>";     $datetime=date("Y-m-d H:i",$mktime);    echo $datetime;    echo "<hr/>";    //strtotime() 函數用於將英文文本字串表示的日期轉換為時間戳記    $strtime = "2015-10-11 12:10";    $timestr = strtotime("$strtime");    echo $timestr;    echo "<hr/>";     echo date("Y-m-d H:i",$timestr);     echo "<hr/>";         //要求使用者在登陸網站在2小時後失效而需要重新登入的例子    $expiration = time()+2*3600;//得到目前時間延遲2小時候的時間戳記    echo $expiration;?>


相關文章

聯繫我們

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