You are here: Re: Convert a date format « PHP Programming Language « IT news, forums, messages
Re: Convert a date format

Posted by Colin McKinnon on 12/18/33 11:49

NC wrote:

> Des wrote:
>>
>> I am displaying records from a table including a stored date. When
>> display $row[Date], i get the obvious 2006-05-21. However this is not
>> what the guy wants. He wants 21-May-2006.
>
> First of all, make it a habit to write $row['Date'], not $row[Date].

Good advice.

> The latter works for now, but may stop working in the future without
> warning. This said, the code snippet you are looking for can look like
> this:
>
> date('j-M-Y', strtotime($row['Date']))
>

strtotime() is very americanized. And 32 bit timestamps suck. A better
solution is to do the formatting in the DBMS if possible - assuming it's
MySQL, then use the DATE_FORMAT() function for Oracle, TO_CHAR() - don't
know about the rest.

HTH

C.

 

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

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