SiteBlog 2 Mini-Tutorial: Changing Date and Time Format

Recognizing The Format
PHP and Date Function
Changing the Format in SiteBlog 2


RECOGNIZING THE FORMAT

NOTE: This tutorial is not intended to demonstrate how to change the time or date (SiteBlog 2 Guide > Writing a New Article > Advanced Editing Mode > Edit Timestamp) on your blog, but rather the format itself.

The default format for the date is month/day/year and hour:minute am/pm for time. For example, 2/17/2005 and 1:30 pm. If you are not satisfied with this format, then you can change it by using the proper PHP strings in the admin panel, General Options.

PHP AND DATE FUNCTION

SiteBlog 2 was created using the PHP language, and thus uses its built-in formatting functions. In its PHP string version, the default date format, "month/day/year", converts to "n/j/Y" and "hour:minute am/pm" converts to "g:i a". Although it appears rather cryptic, it's actually quite literal in its conversions.

Fortunately, it is not necessary to understand PHP or even the date function to be able to modify the format in SiteBlog 2. Let's view the option in SiteBlog 2's admin panel:

The only requirement for changing the format is knowing which string represents which component of time or date. To that end, here is a list of all possible format options.

As you can see, the "n" string is a numeric representation of a month; "j" is the day; "Y" is a four-digit year. Similarly, "g" is the 12-hour format of an hour; "i" is the minutes; and "a" is lowercase am or pm.

Note the use of "/" in between date strings and the space in between "i" and "a". SiteBlog 2 will convert any date function string and directly mirror any other character in the exact same spacing.

CHANGING THE FORMAT IN SITEBLOG 2

Let's change the date format to appear as:

Thursday, February 17, 2005

How would you arrange the strings? Refer back to the PHP date page.

The proper arrangement is:

"l" (lower-case L) is the full name of the day.
"F" is the full name of the month.
"j" is the numeric day.
"Y" is the four-digit year.

Note the the commas and the spaces; they reflect exactly the appearance of the intended format.


©Copyright 2005 Hostway Corporation. All Rights Reserved.
Web Hosting | Domain Name Registration | Email | Managed Hosting