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-d
d.
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.
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
Post a Comment