date_current_datetime

返回当前时刻的日期时间值。返回的时间基于 UTC,在其他函数 (如 date_get_daydate_datetime_string 等) 中使用时,只会转换为您选择的 时区

 

语法:

date_current_datetime();

 

返回:

Datetime

 

例子:

myhour = date_get_hour(date_current_datetime());
myday = date_get_day(date_current_datetime());

这会将本地变量 myhour 设置为当前时间的小时,并将 myday 设置为当前日期的日期。尽管 date_current_time() 以 UTC 为单位返回时间,但默认情况下,您从 date_get_hour 和 date_get_day 函数获取的时间会转换为本地时间 (除非在 date_set_timezone 中更改)。