In WordPress you sometimes need to show dates and time. For example, when you want to show date or
time below a WordPress post showing when that post was posted or the article publishing date and time. You also need to show date in your blog copyright notice. You may also want to show dates and time in Recent post tabular form or most viewed posts, etc. You may have to show dates and time in many palces else where. So how to do that?
To show dates and time, you will have to use some PHP functions. They will show date,time in any form you desire. You may customize the form in which the dates or time are displayed. Certain WordPres tag functions are used to display date and time information. “the_date()” and “the_time()” are a few examples of this.
Some of these functions accept a parameter called a format string that allows you to determine how the date or time is going to be displayed. The format string is a template in which various parts of the date are combined using format characters to generate a date in the specified format according to your wish.
Some format strings:
- l, F j, Y –> Monday, February 8, 2010
- F j, Y –> February 8, 2010
There are almost innumerable combinations and styles you can create.
Here is what each format character in the string above represents:
l= Full name for day of the week.F= Full name for the month.j= The day of the month.Y= The year in 4 digits (Using lower-case “y” gives the year’s last 2 digits like 09 or 10,etc.)
If you use commas in the code, they will be read as simple text. They won’t have any affect on the code. A “,” will display “,”.
As WordPress is written in the programming language PHP, the date formatting functions in WordPress use PHP’s built-in date formatting functions. You can use the date format characters specified on the PHP website for displaying dates and times in WordPress. All of them there will work in WordPress.
The code
will display Monday, February 8, 2010.<?php the_time('l, F j, Y') ?>
You can customize l, F j, Y according to your wish and look you want.
That’s it for today! Stick to Blogging Junction for new posts!

Posted On February 9, 2010 At 3:16 PM
By
Posted In The Categories:
This Post Has Got 8 Comments





Helpful post for WP bloggers
Thanks Basant! Great that you found the post helpful!
Time is very important! time is equal to gold!
Time is gold in my opinion! BTW you are not wrong.
@ Pubudu Kodikara, Saksham Talwar …
Golden words at the right time
Thanks!
Thanks for the tip. They use PHP based date function. I prefer the default format.
You’re welcome! Yeah they use PHP based date function like used in other PHP applications.