current_datetime

函数
current_datetime ( No parameters )
返回值
  • (DateTimeImmutable) Date and time object.
定义位置
相关方法
current_timecurrent_actionget_current_themecurrent_theme_infocurrent_filter
引入
5.3.0
弃用
-

current_datetime: 这个函数以DateTime对象的形式返回当前时间,时区设置为UTC。这对于在WordPress中处理日期和时间非常有用,因为它提供了一个在不同时区和地区的一致和可靠的时间戳。

使用网站的时区将当前时间检索为一个对象。

function current_datetime() {
	return new DateTimeImmutable( 'now', wp_timezone() );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 20:33:00

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: