You are here: Re: Date Formatting Help « All PHP « IT news, forums, messages
Re: Date Formatting Help

Posted by Paul on 05/26/05 00:35

Chris wrote:
> I'm a PHP newbie and I am stuck!
>
> Please take a look at the following page - http://bororules.cogia.net/ - Notice on the front page I have the latest news. I would
> like to format the date of the news item so that it reads 25th May 2005 instead of the 2005-05-25 format that it is in now, this
> is where I am stuck.
>
> All the PHP books I have read tell you how to format the date when calling from the timestamp function Date() etc but I cannot
> find out how to format the value as it is called from a MySQL database field. I am looking for some guidance as to how to format
> that date.
>
> Also does anyone know how I restrict the very top news item (with image) to the latest news item, by date and also have that
> particular news item not included on the list below. I have tried to filter using two record sets as follows:
>
> - news filters the list of news items with the filter set up as date <= curdate
>
> - news2 filters the very top news item and is set up as date = curdate.
>
> First off I am not sure if curdate is right for filtering database field (formatted as date) and second if I do the above I assume
> I would still get the latest news item in the long list.
>
> Any help is much appreciated.
>
> --
> Regards,
> Chris.
>
>

The date you are trying to format is stored as a date field in mysql I
assume not a timestamp?

If so... use something like this...

$formatDate = date("jS F Y", strtotime($row['date_field']));

That should do it..

 

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

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