2025年01月28日 建站教程
wordpress如何利用current_time()函数获取当前时间,下面web建站小编给大家详细介绍一下具体用法!
函数源码:
function current_time( $type, $gmt = 0 ) {
if ( 'timestamp' === $type || 'U' === $type ) {
return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
}
if ( 'mysql' === $type ) {
$type = 'Y-m-d H:i:s';
}
$timezone = $gmt ? new DateTimeZone( 'UTC' ) : wp_timezone();
$datetime = new DateTime( 'now', $timezone );
return $datetime->format( $type );
}
本文链接:http://so.lmcjl.com/news/22183/