RE: [PHP] format date

From: Date: Tue, 16 Apr 2002 17:41:13 +0000
Subject: RE: [PHP] format date
Groups: php.general 
Request: Send a blank email to php-general+get-93228@lists.php.net to get a copy of this message
Hey Alex, I use a short function like this because the date is really just a string you can pick it apart and re-arrange it. function Format_Date($Date){ return $Date = ((substr($Date,6,2))."-".(substr($Date,0,2))."-".(substr($Date,3,2))); } Steve. -----Original Message----- From: Alex [mailto:aarmis@hotmail.com] Sent: Tuesday, April 16, 2002 1:36 PM To: php-general@lists.php.net Subject: [PHP] format date I just started with php and am trying to display a query result for a date field as mm/dd/yyyy instead of mysql's yyyy-mm-dd. I looked through some books and found the use of DATE_FORMAT to covert the dates. Is there any other way to format the date? Thanks My script looks like this: $month_1 = ($date_month_1); $day_1 = ($date_day_1); $year_1 = ($date_year_1); $month_2 = ($date_month_2); $day_2 = ($date_day_2); $year_2 = ($date_year_2); $query = "SELECT * FROM tablename where date >= '$year_1-month_1-$day_1-' AND date <= '$year_2-$month_2-$day_2'"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo "<p>Number of records found: ".$num_results."</p>"; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "<p><strong>".($i+1).". ID: "; echo ($row["id"]); echo "</strong><br>First name: "; echo ($row["fname"]); echo "<br>Last name: "; echo ($row["lname"]); echo "<br>Date: "; echo ($row["date"]); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#93228) next »