Title: current_datetime
Published: November 12, 2019
Last modified: August 20, 2026

---

# current_datetime(): DateTimeImmutable

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#wp--skip-link--target)

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

## 󠀁[Return](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#return)󠁿

 DateTimeImmutable Date and time object.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/functions.php#L101)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/functions.php#L101-L103)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_timezone()](https://developer.wordpress.org/reference/functions/wp_timezone/)`wp-includes/functions.php` |

Retrieves the timezone of the site as a `DateTimeZone` object.

  |

| Used by | Description | 
| [wp_dashboard_recent_posts()](https://developer.wordpress.org/reference/functions/wp_dashboard_recent_posts/)`wp-admin/includes/dashboard.php` |

Generates Publishing Soon and Recently Published sections.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/current_datetime/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcurrent_datetime%2F)
before being able to contribute a note or feedback.