PHP

PHP 时间函数

2020-04-24  本文已影响0人  887d1fc86fe6
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <?php
    echo '从1970年1月1日0:0:0到现在供经过了多少秒:', time(); // 1587722319
    echo '从1970年1月1日0:0:0到现在供经过了多少秒:', microtime(true); // 1587722319.8593
    // 严格来说前面是小数部分,后面是秒,需要相加起来就是当前时间
    echo '从1970年1月1日0:0:0到现在供经过了多少秒:', microtime(false); // 0.85927000 1587722319

    // 创建一个时间,参数为:时 分 秒 月 日 年
    echo mktime(10, 8, 5, 7, 12, 2020); // 1594519685

    echo date('Y-m-d H:i:s'); // 2020-04-24 18:03:08
    echo idate('Y'); // 2020
    echo idate('s'); // 08
  ?>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读