current_datetime() WordPress Function

The current_datetime() function is used to retrieve the current date and time. This function is useful for display purposes, such as in a date or time picker.

current_datetime() #

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


Return

(DateTimeImmutable) Date and time object.


Top ↑

Source

File: wp-includes/functions.php

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


Top ↑

Changelog

Changelog
VersionDescription
5.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More