<?php /** * Created by PhpStorm. * User: jefferyteng * Date: 2018/8/28 * Time: 10:00 *//*1、直接打印微秒0.24754300 1535423356*/echo(microtime());echo "
";/*2、十三位时间戳,包含毫秒1535423356248*/function msectime(){list($msec, $sec) = explode(' ', microtime());$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);return $msectime;}echo msectime();echo "
";//3、获取当前系统时间并打印$date = new DateTime();echo $date->format('Y-m-d H:i:s');echo "
";/*4、完整的时间:2018-08-28 10:29:16 247591*/function udate($format = 'u', $utimestamp = null){if (is_null($utimestamp)){$utimestamp = microtime(true);}$timestamp = floor($utimestamp);$milliseconds = round(($utimestamp - $timestamp) * 1000000);//改这里的数值控制毫秒位数return date(preg_replace('`(?";//5、只要毫秒+微秒:247624function milliseconds($format = 'u', $utimestamp = null){if (is_null($utimestamp)){$utimestamp = microtime(true);}$timestamp = floor($utimestamp);$milliseconds = round(($utimestamp - $timestamp) * 1000000);//改这里的数值控制毫秒位数return $milliseconds;}echo milliseconds();
php怎么把时间精确到毫秒,PHP输出时间精确到毫秒
最新推荐文章于 2023-11-04 08:00:00 发布