Sometimes, you may want to display the current date or time inside one of your posts and pages and have it update dynamically every time the page is loaded.
We can achieve this quite simply by creating an easy shortcode in your WordPress installation.
To do this, add the following code to the bottom of your functions.php file. This code includes a function which checks the current date/time and then returns it when the shortcode is inserted in a post or page. You can change the way the date/time appears by using PHP date formats; the way I’ve written the code in this tutorial will return a value such as May 18, 2011.
Now all you need to do to display the date is write your shortcode into one of your posts or pages; in this case, the shortcode is [date].