|
Posted by J.O. Aho on 08/06/06 03:18
Matt wrote:
> I am attempting to format date values returned from a database
>
> // snippet of code
> while ($myrow = mysql_fetch_array($result)) {
> $offr_vsdate = $myrow[offr_vsdate];
> //
>
> If I echo the date 'as it comes'
> echo $offer_vsdate;
> I get the output: 2006-08-01
>
> But if I try to format the date as follows
> echo date("d/m/Y",$offer_vsdate);
> I get the output: 01/01/1970
date don't take a string as argument, it needs a time value.
http://www.php.net/manual/en/function.date.php
You can try with
echo date("d/m/Y",strtotime($offer_vsdate));
or with
$darray=explode("-",$offer_vsdate);
echo date("d/m/Y",mktime(0,0,0,$darray[1],$darray[2],$darray[0]));
The later will at least work.
//Aho
Navigation:
[Reply to this message]
|