--- Pandora <[EMAIL PROTECTED]> wrote: > On a large database where speed is very important is it better to format the > date using the MySQL DATE_FORMAT function in a query or to retrieve the date > and then use PHP to format the date? > > Currently the site is using the MySQL DATE_FORMAT function but I've been > told it is better to use PHP date functions for speed improvements. The site > depends upon the date quite a lot and it would take much work to change all > the queries and use PHP for the formatting but it would be worth doing if it > resulted in an increase in speed. I would welcome your views on this. > > Thank you very much. > > Janet
There may be a difference between the execution time of 1,000 MySQL date_format functions vs a similar number of PHP date functions. I have not benchmarked it. However, the decision about which place to make your date formatting often is influenced by other factors than raw speed, especially if you are perfoming fewer than 1,000 such formats on a given page. For most of my applications, the dates I store are well beyond the 1970-2042 range of years which the PHP functions can handle due to the limitations of most operating systems. MySQL dates can literally be any value from 1 Jan 1000 to 31 Dec 9999 and the MySQL functions for formatting and otherwise processing dates can handle this range. James
