Date confusion

From: Date: Thu, 28 Jul 2005 06:28:48 +0000
Subject: Date confusion
Groups: php.general 
Request: Send a blank email to php-general+get-219463@lists.php.net to get a copy of this message
Hi, I must admit I am surprised at the paucity of date and time functions in PHP. I have a date stored in a MySQL database in field of datatype date. PHP doesn't seem to have a function I can use to format it for print. I tried the following but regardless of the value in the date field, it displays as 'Wednesday December 31, 1969' (I know this is the day before the UNIX epoch.). echo '<p>'.date('l F j, Y',$start_date).'</p>'; I tried casting the field to datetime, but it didn't pass the parser. Finally I did the following, which seems to work, but is awfully convoluted: echo '<p>Date: '.date('l F j, Y',strtotime($start_date).'</p>'; The other thing I'm concerned about is that strtotime takes the locale into consideration. I don't want it adjusting the date - I just want it printed out. Is there a better way to do this?

« previous php.general (#219463) next »