Mar 09, 2010

Getting the_time() to work

So someone was curious about how to get the_time to work in WordPress. Here’s an example (taken from this theme I customized) on how to use the_time:

This is the basic way to show the month, day and year like shown in my posts:

the_time('F j, Y');

However if you want to do something with the actual timestamp (such as showing time you posted), you can use this:

the_time('g:i a');

Refer to the chart below to know what character to use in to customize the display (You’d just change the F j, Y in the_time(‘F j, Y) ).

Day of month
d Numeric, with leading zeros 01–31
j Numeric, without leading zeros 1–31
S English ordinal suffix, use after j st, nd, rd or th
Weekday
l Full name  (lowercase ‘L’) Sunday – Saturday
D Three letter name Mon – Sun
Month
m Numeric, with leading zeros 01–12
n Numeric, without leading zeros 1–12
F Textual full January – December
M Textual three letters Jan – Dec
Year
Y Numeric, 4 digits Eg., 1999, 2003
y Numeric, 2 digits Eg., 99, 03
Time
g Hour, 12-hour, without leading zeros 1–12
h Hour, 12-hour, with leading zeros 01–12
a Lowercase am, pm
A Uppercase AM, PM
G Hour, 24-hour, without leading zeros 0-23
H Hour, 24-hour, with leading zeros 00-23
i Minutes, with leading zeros 00-59
s Seconds, with leading zeros 00-59
T Timezone abbreviation Eg., EST, MDT …
Full Date/Time
c ISO 8601 2004-02-12T15:19:21+00:00
r RFC 2822 Thu, 21 Dec 2000 16:01:07 +0200
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • StumbleUpon

Leave a Reply

CommentLuv Enabled