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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

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

Post 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?
Phaaze
Forum Newbie
Posts: 2
Joined: Tue Oct 06, 2009 10:00 pm

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

Post 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.
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

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

Post by edawson003 »

Thanks, that worked. I implemented date('m-d-Y',strtotime($todaysdt));
Post Reply