Formatting your sNews article publish date
I browse various sNews CMS powered sites quite a bit, and one thing I've noticed is most all of them use the default date settings for their articles. Such as; 24.06.2009. 13:15
Now I'm not certain why that is, while that doesn't seem to the most readable format to me, perhaps it suits them best. However I'm guessing the majority of folks don't know they can change it, or either they don't understand the somewhat cryptic letters used to format them. I will attempt to show you how to modify this setting if you so choose.
Look within the sNews administration panel, check under;
- Under Site, click settings
- Click Time and Locale settings
- Edit the Date Format box
Now you will see the default settings, most likely it will be "d.m.Y. H:i'". This is what we want to change, and it's easier than you may think, as it uses the PHP date function. I will break this down into the most common elements for formatting the date, we want to use the days, months, years, and time (hours, minutes, seconds, am/pm), and possibly the timezone. Take a minute and look at the chart below, each character represents a formatting option.
|Character||Description||Example returned values|
|d||Day of the month, 2 digits with leading zeros||01 to 31|
|D||A textual representation of a day, three letters||Mon through Sun|
|j||Day of the month without leading zeros||1 to 31|
|l (lowercase 'L')||A full textual representation of the day of the week||Sunday through Saturday|
|S||English ordinal suffix for the day of the month, 2 characters||st, nd, rd or th. Works well with j|
|F||A full textual representation of a month, such as January or March||January through December|
|m||Numeric representation of a month, with leading zeros||01 through 12|
|M||A short textual representation of a month, three letters||Jan through Dec|
|n||Numeric representation of a month, without leading zeros||1 through 12|
|Y||A full numeric representation of a year, 4 digits||Examples: 1999 or 2003|
|y||A two digit representation of a year||Examples: 99 or 03|
|a||Lowercase Ante meridiem and Post meridiem||am or pm|
|A||Uppercase Ante meridiem and Post meridiem||AM or PM|
|g||12-hour format of an hour without leading zeros||1 through 12|
|G||24-hour format of an hour without leading zeros||0 through 23|
|h||12-hour format of an hour with leading zeros||01 through 12|
|H||24-hour format of an hour with leading zeros||00 through 23|
|i||Minutes with leading zeros||00 to 59|
|s||Seconds, with leading zeros||00 through 59|
|T||Timezone abbreviation||Examples: EST, MDT|
So, for example, if you wanted the date formatted like mine;
Jun 26th, 2009 @ 7:32 am EDT
Then you would insert M jS, Y @ g:i a T in the Date Format field.
If you wanted;
March 26 2009
Simply insert F j Y, etc. etc.
What if you want to include plain text in the output? That's easy, you must escape each text character with a backslash (just to be safe, as unrecognized characters/symbols such as the @ symbol are printed as plain text too). For an extreme example, if you wanted your date to be formatted like this;
posted on Saturday the 19th of June, 2009 at 9:31PM
Then you'd enter \p\o\s\t\e\d \o\n l \t\h\e jS \o\f F, Y \a\t g:iA. Any questions, drop a comment, I'd be happy to assist.