zoukankan      html  css  js  c++  java
  • php strtotime 函数UNIX时间戳

    int strtotime ( string time [, int now]) 本函数预期接受一个包含英文日期格式的字符串并尝试将其解析为 UNIX 时间戳。
    如果 time 的格式是绝对时间则 now 参数不起作用。如果 time 的格式是相对时间则其所相对的时间由 now 提供,或者如果未提供 now 参数时用当前时间。失败时返回 -1。
    <?php
    /**
    * php时间戳的例子

    * by www.jbxue.com
    */
    echo strtotime ("now"), " ";
    echo strtotime ("10 September 2000"), " ";
    echo strtotime ("+1 day"), " ";
    echo strtotime ("+1 week"), " ";
    echo strtotime ("+1 week 2 days 4 hours 2 seconds"), " ";
    echo strtotime ("next Thursday"), " ";
    echo strtotime ("last Monday"), " ";

    //
    $str
     = 'Not Good';
    if (($timestamp = strtotime($str)) === -1) {
    echo "The string ($str) is bogus";
    else {
    echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
    }
    ?>

    这个效果和用mktime()是一样的. 
  • 相关阅读:
    JZOJ5906 传送门
    JZOJ5907 轻功
    JZOJ5904 刺客信条
    JZOJ5347 遥远的金字塔
    JZOJ5344 摘果子
    JZOJ4742 单峰
    JZOJ4725 质数序列
    JZOJ2499 东风谷早苗
    JZOJ4737 金色丝线将瞬间一分为二
    最后的财产——模板大全
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3278907.html
Copyright © 2011-2022 走看看