Format your sNews article publish date to make it more reader friendly
filed under: sNews CMS
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 Site --> Settings --> Time and Locale settings --> Date Format:
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 |
|---|---|---|
| Day | --- | --- |
| 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 |
| Month | --- | --- |
| 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 |
| Year | --- | --- |
| 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 |
| Time | --- | --- |
| 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 |
| Timezone | --- | --- |
| 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.
3 comments
Add a new comment »Categories
Recent Entries
Recent Comments
- Dede (I checked it today in a shop. GT2 had some troubles with six ...)
- Matt (Bintang, You need to re-direct the url, try ...)
- jesth (Ohh.. why didn't I think of that, thanks alot.)
- Matt (Dede, I don't have Gran Turismo 2, any of the 2nd+ generation ...)
- Matt (Jesth, Just change the if condition, instead of looking for ...)
- jesth (Hi (again) Was wondering, is it possible to make it ...)
- Bintang Sembilan (Matt, thanks for your modd. I have apply it to my ...)
- Dede (Hello there. Can you check something for me? I want to buy ...)
- Matt (I think it's a driver issue Terrence, or it was a driver issue. ...)
Popular Entries
- Light-weight related articles mod for sNews 1.7 (4.5/5)
- Image / math hybrid captcha version 2, vastly improved (4.42/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.4/5)
- Compact archives for sNews 1.7 (4.4/5)
- sNews Ajax Polls mod now available (4.38/5)
- Pretty date and comments bars in sNews CMS (4.35/5)
- Page caching mod for sNews 1.7 (4.33/5)
- Gravatar mod for sNews 1.7 (4.29/5)
- An improved tag cloud for sNews 1.7 (4.29/5)
Oct 30th, 2009 at 11:28 pm
Hello Matt, I 'm trying snews 1.7, edited the template to go back to 1.6's (better I think than the new one), but I've got a problem. 2 problems, in fact.
First: I cannot publish more than 1 (one) article, and I don't know why. No matter which User I choose -both admin-, the process shows everything's OK, but the article won't show anyway.
Second: snews site is down, so I cannot read any solution in forums or faq.
I want to know if this cms still works (I can see it DOES for your site =)...), but I don't want to go back to joomla, so I need your help.
If that is possible.
Thank you.
Greetings from Argentina.
Oct 31st, 2009 at 3:46 pm
Hi Al,
I'll do what I can tyo help you, but I have to say I've never really used sNews before 1.7.
So when you save an article, it's not appearing, is that what you're saying? Can you edit it after, just not view it when published? Have you checked the database to see if the article is created?
Ah, yeah, the snewcms.com siter has been off and on a bit over the last week or so, I've noticed as wll, it's up right now though.
--Matt
Nov 1st, 2009 at 9:29 pm
Hello Matt!
Thanks for your answer to my request.
I think it was a hosting problem, as they had "frozen" ftp service, so I want to believe they were backing up everything.
After that, I decided to install 1.7 clean, no mods, and it's working fine by now.
The only addon I installed was the Tiny MCE editor, excellent tool.
Thank you again for your time, I'll be back as I've bookmarked your site because it is very -for me- necessary.
Greetings from Argentina!
Al.