Skip to content

日期时间

php
<?php
// 格式化输出到网页上
function dd(...$args) {
    echo '<pre>';
    var_dump(...$args);
    echo '<pre>';
}

// 获取现在的时间
$now = date('Y-m-d H:i:s'); // string(19) "2025-12-29 13:04:00"
dd($now);

// 获取当前 unix 时间戳: 11 位(单位:秒)
$time = time();
dd($time); // int(1767014231)

// 获取当前 unix 时间戳: 13 位(单位:毫秒)
$micro_time = microtime(true);
dd($micro_time); // float(1767014285.100185)

// 将字符串转时间戳
$time = strtotime('2025-12-20 12:12:30');
dd($time); // int(1766232750)

Released under the MIT License.