format date

From: Date: Tue, 16 Apr 2002 17:35:34 +0000
Subject: format date
Groups: php.general 
Request: Send a blank email to php-general+get-93227@lists.php.net to get a copy of this message
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"]);

« previous php.general (#93227) next »