smarty - reformat date that is pulled from database table -


i have website uses smarty templates.

i have table in db called posts has various columns, 1 being "date_added". managed have displayed on posts editing 1 of smarty templates "posts" however, date format yyyy-mm-dd.

is there easy way me change this? perhaps jquery?

ideally, want show abbreviated month, day positioned next it. blog style post, isn't wordpress.

right smartytemplate shows date_added reads this:

{$posts[i].date_added|stripslashes|nl2br} 

where posts table , date_added column in table.

an exact example can seen here in top right corner of each post.

http://www.elegantthemes.com/preview/lightbright/

does have suggestion of how can achieve desired request?

if looking javascript solution, can take @ incredible js library momentjs. lightweight , numerous date , time formats.

http://momentjs.com/

just include minified script file in html .

for exact case, use momentjs such: first create momentjs date object:

var moment_date = moment(date_from_database, "yyyy-mm-dd"); 

then display date want:

var date_string = moment_date.format("mmm dd");  // ex. = "mar 03"      

more documentation here: http://momentjs.com/docs/#/displaying/

then can use dom manipulation library (jquery example) place string somewhere in html

good luck - k


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -