note 34279 deleted from function.date by pollita

From: Date: Sat, 26 Jul 2003 16:55:10 +0000
Subject: note 34279 deleted from function.date by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52710@lists.php.net to get a copy of this message
Note Submitter: Jonathan Haun ---- I had this problem that I noticed other people are having with trying to get the MySQL date that was inserted into the database (created in MySQL like this: my_date date DEFAULT '0000-00-00' NOT NULL) to convert into something the typical humanoid is more capable of reading. Something familiar. So the date gets inserted into the database in a format like this: 2003-06-12, but I want it to look like this: 'Thursday, 12 June 2003'. I did a the database query using PHP for the date, put it in the variable name $my_date, and wanted to convert that using the strtotime(); function. The problem I always ended up with the year being 1969, while everything else was correct. I am not sure why, but it scared me, so I messed around a little bit. I ended up finding a very good solution, which is also very simple. Check it out. $date_created = date('l, d F Y',strtotime($row["my_date"])); This gives me the string in the format I wanted. Knowing this, I can easily take any MySQL date and format it to any way I choose, gregorian calendarwise. I hope that helps people out with similar problems formatting dates. Ciao, Jonathan

« previous php.notes (#52710) next »