You Are Here:- Home / Wordpress / How To Customize The Time And Date In WordPress?

How To Customize The Time And Date In WordPress?


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:

  1. l, F j, Y –> Monday, February 8, 2010
  2. 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

<?php the_time('l, F j, Y') ?>

will display Monday, February 8, 2010.

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!


If You Enjoyed Reading This Post, Please Consider To Leave A Comment And / Or Subscribe To The Feed And Get Future Articles Delivered To Your Feed Reader Regularly.

Related Posts


8 Responses to “How To Customize The Time And Date In WordPress?”

Comments

  1. Basant Singh says:

    Helpful post for WP bloggers

  2. Time is very important! time is equal to gold! :D

  3. abhi says:

    Thanks for the tip. They use PHP based date function. I prefer the default format.

Leave A Reply

CommentLuv Enabled

Copyright © 2009 - 2010 Blogging Junction. All Rights Reserved.
Blogging Junction Is Proudly Powered By Wordpress And Blog Design By New WP Themes