get_the_date

Home » Functions » get_the_date

Function Name: get_the_date

When creating a blog or website using WordPress, it’s essential to have a function that retrieves the date of a post or page. That’s where the get_the_date() function comes in. This function retrieves the date of the current post or of a specified post and returns it in a readable format.

The get_the_date() function is a part of the WordPress Template Tags, and it can be added anywhere in your template file to display the date of a post or page. The function takes an optional parameter, which is the date format that you want to display. If you don’t specify a format, it will display the date in the format set in your WordPress settings.

Example Usage Code:

Let’s say you want to display the date of the current post in the format "M j, Y" (e.g., Jan 1, 2022). You can add the following code to your template file:

Posted on

This code will retrieve the current post’s date and display it in the specified format. If you don’t specify a format, it will display the date in the default format set in your WordPress settings.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.