View Full Version : Resolved date issues...

05-09-2009, 10:50 PM
hi folks,

I have a small issue with some coding work, and wonder if someone could shed some light on for me please..

print "<td>". date('d-m-y',$row['fldEndDate']) ."</td>";

the date within the database is this: 2009-04-30 00:00:00
however - on the output I'd like it to show 30-04-2009

it's currently displaying the 01-01-70

Could anyone aid my blindness here....!?! lol

05-09-2009, 11:08 PM
use explode.... :thumbsup:

if u want i can show u an example...

05-09-2009, 11:20 PM
date expects an integer value representing a timestamp. You can convert it prior to querying (tounixtime(), something like that), or you can use php's strtotime to convert that as well. This would work only in PHP5+
MySQL will let you format you're date differently as well. Check this link out for info on that: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

Oh btw, my recommendation is to do it from the PHP side of things. MySQL does make it easier, but I like the control that my application provides for me when it comes to formatting.

05-09-2009, 11:22 PM
Cheers folks!

new code now
thanks to @jasonatennui on twitter too.

Thanks again