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中處理日期和時間非常有用,因為它提供了一個在不同時區和地區的一致和可靠的時間戳。

使用網站的時區將當前時間檢索為一個物件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function current_datetime() {
return new DateTimeImmutable( 'now', wp_timezone() );
}
function current_datetime() { return new DateTimeImmutable( 'now', wp_timezone() ); }
function current_datetime() {
	return new DateTimeImmutable( 'now', wp_timezone() );
}

常見問題

FAQs
檢視更多 >