WordPress 中文文档

Function Reference/current time

From WordPress Chinese

Jump to: navigation, search

目录

描述

返回当前时间或unix时间戳

用法

<?php echo current_time($type, $gmt = 0); ?>

例子

用法

返回两种格式的系统当前时间.

<?php echo('Current time: ' . current_time(mysql) . '<br />'); ?>
<?php echo('Current timestamp: ' . current_time(timestamp)); ?>
Current time: 2005-08-05 10:41:13
Current timestamp: 1123238473

参数$gmt的作用是是否采用时差补偿。默认为false,wp中后台可以设置用户所在地的当前时差。保存于wp_config表中 key gmt_offset。

如想获得用户所在地的当前时间 采用current_time('mysql',1)即可

Parameters

Template:ParameterTemplate:Copyedit

用户