Show Month Name, Year & Date in WordPress Post, Page, Widget

Simple instructions on how to show the name of current month, year or any date information on WordPress posts, pages and widgets; without a plugin.

Note! You will only need some functions.php editing skills.

Month Calendar

Not just Google but also blog visitors like to have the feeling that posts are up-to-date; and displaying the name of the current month, date will do just that.

Few basics:

The code below should be added to your functions.php file (usually the bottom); do that from WordPress dashboard: Appearance –> Editor –> Theme Functions.

This will create a shortcode “example: [monthname]” that you can place anywhere in a post or page; if you want to put that into a text or html widget — you will need to add the following code to functions.php first:

add_filter( 'widget_text', 'shortcode_unautop' );
add_filter( 'widget_text', 'do_shortcode' );

The part “date(‘D, j F Y’)” defines the date format; you can edit it with many different parameters (see examples below) — you can find a full list here.

By default the server time is used — I’ve added examples of how to show the date from a different time zone — see list of supported time zones.

Few warnings:

Make sure that you are using a WordPress child theme or otherwise the functions.php will be overwritten by any theme updates.

If you make a mistake in functions.php; WordPress can stop working until you remove any broken code from functions.php.

Then let’s get to copy pasting:

This shortcode “[monthname]” will show the full name of the current month:

function monthname_function() {
$currentmonth = date('F');
return $currentmonth; }

add_shortcode('monthname', 'monthname_function');

Example: Today is the month of April — am I correct?

This shortcode “[yearnumber]” will show the number of the current year:

function yearnumber_function() {
$currentyear = date('Y');
return $currentyear; }

add_shortcode('yearnumber', 'yearnumber_function');

Example: The year is 2024 — and you’re not getting younger.

This shortcode “[fulldate]” will show the full date:

function fulldate_function() {
$currentdate = date('l, j F Y');
return $currentdate; }

add_shortcode('fulldate', 'fulldate_function');

Example: Today’s date is: Thursday, 18 April 2024 — says my server.

This shortcode “[weekdaynametokyo]” will show the weekday in Tokyo:

function weekdaynametokyo_function() {
$currentweekday = date('l');
return $currentweekday; }

add_shortcode('weekdaynametokyo', 'weekdaynametokyo_function');

This shortcode “[weekdaynameny]” will show the weekday in New York:

function weekdaynameny_function() {
$currentweekday = date('l');
return $currentweekday; }

add_shortcode('weekdaynameny', 'weekdaynameny_function');

Example: It’s Thursday in Tokyo; but Thursday in New York.

And that’s all there is to it; no WordPress plugins needed.
Is the month name, year, or date info displaying correctly?
Comments, questions are welcome!

2 thoughts on “Show Month Name, Year & Date in WordPress Post, Page, Widget”

  1. Hi Tim,

    thank you for this great post. I have tried it for my WP Blog. It has worked perfekt within the content post area. Unfortunately it din’t work for the titles and SEO Yoast SERP Titles.

    Maybe you have an idea to get it also working for the Blog Titles?


    • Sorry for the late reply.
      Unfortunately, this won’t work for titles, etc.
      Anything beyond the “content post area” is not as easy.
      Thanks for your comment!


Leave a Comment