...

View Full Version : SYSDATE() views



welsh_boy01
11-30-2006, 11:00 AM
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 :)

WB

Tyree
11-30-2006, 02: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 ;)

firepages
12-01-2006, 01: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum