Re: mysql/php date functions..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Moseby wrote:
> 
> Hi Bruce!
> 
> MySQL and PHP both have extensive built-in date functions that are clearly
> documented and extraordinarily easy to use. For the vast majority of
> situations, there is no need to manually write any custom date-handling
> code. The decision to use MySQL or PHP to manipulate a date for a given
> instance depends largely on the particulars of that situation.
> 
> For instance, if you want to increment a MySQL date column by one day, it
> would likely be better to use the MySQL date functions to do it, because to
> use PHP, you have to read the date, manipulate it, then write it back,
> whereas if you use a SQL statement, you can do it with one DB call.
> 
> See:
> http://www.php.net/datetime
> http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
> 
> Cheers!
> 

Just my 0.02 euros.

When I need to use dates in PHP *and* MySQL I usually use the UNIX
timestamp (seconds since the epoch, that is, the PHP http://php.net/time
output).
This way I can (quite) easily calculate date differences etc. (usually
all the calculations are done in PHP, also when building SQL queries).

As I said, just my 0.02 euros...

Cheers
Silvio

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux