如何在使用已形成的wordpress时间基础上增加2小时current_time("mysql", false)
?
如何将CURRENT_TIME(“MySQL”,FALSE)形成的WordPress时间加2小时?
1 个回复
最合适的回答,由SO网友:jdm2112 整理而成
WordPresscurrent_time()
以第一个参数中指定的格式返回当前时间。在示例代码中,这是mysql
价值第二个参数表示时区选项。默认值返回站点的“设置”>“常规”页面上指定时区的本地时间或GMT,具体取决于调用函数时提供的值。
https://codex.wordpress.org/Function_Reference/current_time
如果仍然需要时间数学,请使用PHPstrtotime()
函数对此很有用:$now = current_time( \'mysql\' );
echo \'It is currently: \' . $now . \'<br>\';
$later = date( \'Y-m-d H:i:s\', strtotime( $now ) + 7200 ); //7200 seconds = 2 hours
echo \'In 2 hours it will be: \' . $later;
结束