Formatting your sNews article publish date

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
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.

Tags

 

You might like

Comments


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.


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


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.


Hi, Matt -
Interesting case - can't get it - I like to repost my article dated 2009. I've edited it, and like to print a recent date of May 2011. But option list has just 3 positions: 2008/2009/2010. Is this a prob with server time or what?
Thank you very much for your efforts and attention to sNews!


That's odd Joshua, are you sure you're selecting the "Enable" checkbox when changing the publish date when editing the article?

Comments are closed. No new comments allowed.

Copyleft 2002 - 2017 Matt Jones
Hand crafted with HTML5 & CSS3
↑ Back to top