久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php日期轉(zhuǎn)換為時間戳的方法

      php日期轉(zhuǎn)換為時間戳的方法

      PHP 日期轉(zhuǎn)換為時間戳 strtotime 與 mktime 函數(shù)

      日期轉(zhuǎn)換為時間戳

      PHP 提供了函數(shù)可以方便的將各種形式的日期轉(zhuǎn)換為時間戳,該類函數(shù)主要是:

      strtotime():將任何英文文本的日期時間描述解析為時間戳。mktime():從日期取得時間戳。

      strtotime()

      函數(shù)用于將英文文本字符串表示的日期轉(zhuǎn)換為時間戳,為 date() 的反函數(shù),成功返回時間戳,否則返回 FALSE 。

      語法:

      int strtotime ( string time [, int now] )

      參數(shù) time 為被解析的字符串,是根據(jù) GNU 日期輸入格式表示的日期。

      例子:

      <?phpecho strtotime("2009-10-21 16:00:10");//輸出 1256112010 echo strtotime("10 September 2008");//輸出 1220976000 echo strtotime("+1 day"), "<br />"; //輸出明天此時的時間戳 ?>

      mktime()

      mktime() 函數(shù)用于從日期取得時間戳,成功返回時間戳,否則返回 FALSE 。

      語法:

      codeint mktime(時, 分, 秒, 月, 日, 年)

      例子:

      <?php echo mktime(21, 50, 55, 07, 14, 2010);//輸出“1279115455” ?>

      參數(shù)可以從右向左省略,任何省略的參數(shù)會被設置成本地日期和時間的當前值。

      mktime() 在做日期計算和驗證方面很有用,它會自動計算超出范圍的輸入的正確值。例如下面例子輸出的都是 2008-01-01:

      <?php echo date("Y-m-d", mktime(0, 0, 0, 12, 32, 2007)); echo date("Y-m-d", mktime(0, 0, 0, 13, 1, 2007)); ?>

      下個月的最后一天:

      任何給定月份的最后一天都可以被表示為下個月的第 "0" 天,而不是 -1 天,如下面的例子:

      <?php $lastday = mktime(0, 0, 0, 3, 0, 2008); echo strftime("2008年最后一天是:%d", $lastday); ?>

      瀏覽器輸出:

      2008年最后一天是:29

      推薦:《PHP教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號