Page 1 of 1

date('Y-m-d')????

Posted: Tue Oct 06, 2009 9:20 pm
by edawson003
I set up a variable for date that I use to post data in mysql table.

$todaysdt = date('Y-m-d',time());

I would like retrieve the date for display in this format: m-d-yyyy, so I tried date('m-d-Y',$loggeddt), but I get weird results. For instance 2009-10/06 comes back as 12-31-1969. Is there a way I can convert the format of my date?

Re: date('Y-m-d')????

Posted: Tue Oct 06, 2009 10:04 pm
by Phaaze
date() requires the second parameter to be a Unix Timestamp, you can use strtotime() to try and convert your formatted time into a Unix Timestamp.

Re: date('Y-m-d')????

Posted: Tue Oct 06, 2009 10:12 pm
by edawson003
Thanks, that worked. I implemented date('m-d-Y',strtotime($todaysdt));