W3cubDocs

/WordPress

current_datetime(): DateTimeImmutable

Retrieves the current time as an object using the site’s timezone.

Return

DateTimeImmutable Date and time object.

Source

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

Changelog

Version Description
5.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/current_datetime