登 录
/** * * @param <type> $format * @param <type> $utimestamp * @return <type> * @example * * echo udate('H:i:s.u'); 19:31:28.7812 * * echo udate('H:i:s.uuuu'); 19:31:28.78127781277812778127 * * echo udate('Y-M-D H:i:s.u'); 2010-Apr-Thu 19:40:49.484376 * * echo udate('Y-m-d H:i:s.u'); 2010-04-22 20:20:32.453127 * * echo date("Ymd").udate('Hisu'); 20100422201737484376 * * echo date("Ymd").udate('Hisuu'); 20100422201926156251156251 * * @author wulei * @date * */ function udate($format, $utimestamp = null) { if (is_null($utimestamp)) $utimestamp = microtime(true); $timestamp = floor($utimestamp); $milliseconds = round(($utimestamp - $timestamp) * 1000000); return date(preg_replace('`(?<!////)u`', $milliseconds, $format), $timestamp); }
抱歉!评论已关闭.