RE: [PHP] formating date
You can do it by selecting the formatted date from the mysql server using the DATE_FORMAT command which would be: SELECT DATE_FORMAT('%M %D, %Y', date_field_name_or_mysqldate); -Original Message- From: Gronquist, Jim M [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 30, 2003 11:53 AM To: [EMAIL PROTECTED] Subject: [PHP] formating date My script currently works; printing the date that it extracts from mysql table. It prints the date as: 2004-01-29 $mailed=$row["mailed"]; $payment=$row["payment"]; $ID=$row["ID"]; echo "$mailed$payment"; I'm trying to change the format so that the date appears as: January 29, 2004 $mailed=$row["mailed"]; $payment=$row["payment"]; $ID=$row["ID"]; $thisdate=date("F/d/Y",$row->mailed); echo "$thisdate$payment"; This gives the right format, however, it seems to be trying to do the current date rather then my submitted date? Any idea how I do this? - Jim Gronquist Computer Network and Programming Analyst Office of the Bursar Indiana University 812.856.3026 x6-3026 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] formating date
> -Original Message- > > > My script currently works; printing the date that it extracts from mysql > table. > > It prints the date as: > > > > 2004-01-29 > > > > $mailed=$row["mailed"]; > > $payment=$row["payment"]; > > $ID=$row["ID"]; > > echo "$mailed$payment"; > > > > > > I'm trying to change the format so that the date appears as: > > January 29, 2004 > > > > $mailed=$row["mailed"]; > > $payment=$row["payment"]; > > $ID=$row["ID"]; > > $thisdate=date("F/d/Y",$row->mailed); > > echo "$thisdate$payment"; > > > > This gives the right format, however, it seems to be trying to do the > current date rather then my submitted date? > > > > Any idea how I do this? > > > Try this: $mailed=$row["mailed"]; $payment=$row["payment"]; $ID=$row["ID"]; $Timestamp=strtotime($row[mailed]); $thisdate=date("F/d/Y",$Timestamp); echo "$thisdate$payment"; Before you can use date with a string I believe you have to get the timestamp from your string and then use that to format date. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php