Reply to Re: How to format at date field output

Your name:

Reply:


Posted by Jerry Stuckle on 07/25/06 18:59

Andy Jeffries wrote:
> On Tue, 25 Jul 2006 09:46:02 -0400, Jerry Stuckle wrote:
>
>>>I have a field in a database called DateRcvd. At present, it outputs in
>>>my report in the yyyy-mm-dd format. I would like it to display in the
>>>dd/mm/yy format. What is the easiest way to accomplish this?
>>
>>Depends on the database., But most have a function to format the default
>>date to however you want. Check your database documentation.
>>
>>Otherwise you could reformat it in the php code - use substr() or a regex
>>to get the year, month and day, then display them like you wish.
>>
>>Personally I prefer the database function.
>
>
> Personally I prefer Kim André Akerø's solution, it's easier to read and
> programmer time is (in *most* of the work I do) worth more than CPU time.
> However, Kim's method is by far the slowest. To do 10,000 iterations of
> each version:
>
> $ ./test.php
> strtotime/date = 0.5179 seconds
> ereg = 0.0885 seconds
> preg = 0.0435 seconds
> substr = 0.0282 seconds
>
> However, as I rarely do more than one or two conversions like this per
> page impression, and they are on fairly low traffic sites on powerful
> boxes (max is about 5M page impressions per month) I'll stick to most
> readable :-)
>
> Cheers,
>
>
> Andy
>
>
Andy,

Personally, I prefer to let the database handle it. It's generally
faster overall - the database probably had to convert it to yyyy-mm-dd
format in the first place. That way it can convert directly to the
desire format instead of going through two conversions.

And even if it doesn't have to convert it to yyyy-mm-dd, the compiled
code in the database is generally a lot more efficient than the PHP.

And that's the easiest to read!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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