You are here: Re: Date formatting issue « All PHP « IT news, forums, messages
Re: Date formatting issue

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация