RE: [PHP] formating date
| From: | Peter Knight | Date: | Wed, 30 Jul 2003 16:07:04 +0000 |
| Subject: | RE: [PHP] formating date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157538@lists.php.net to get a copy of this message | ||
> -----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
> "<TR><TD>$mailed</TD><TD>$payment</TD></TR>";
>
>
>
>
>
> 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
> "<TR><TD>$thisdate</TD><TD>$payment</TD></TR>";
>
>
>
> 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 "<TR><TD>$thisdate</TD><TD>$payment</TD></TR>";
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