View Full Version : SYSDATE() views

11-30-2006, 12:00 PM
Hi there, I currently store a timestamp in my database to keep track of the last time an entry was updated via the SYSDATE() SQL function.

I was wondering if there was an easy way to display this sysdate in a simple format

so instead of displaying 2006-11-30 04:46:51
it displays "30-Nov-06" or "Today" etc...

Many thanks :)


11-30-2006, 03:57 PM
Check out the date() php function.

Extract the date from your database, set it as a variable and format it with the date() function.

date("d-M-y", $myDate)

If you want it to say "Today" then just run a conditional that asks if date() is equal to date("d-M-y", $myDate). If so, then print "Today" instead of the date.

Easy-Peasy ;)

12-01-2006, 02:17 AM
or look at your DB's built in commands .. e.g. in MySQL you can

"SELECT DATE_FORMAT('timefield','%d-%M-%Y) as pretty_date FROM ...etc