Page 1 of 1

Coding using SQL date_format

Posted: Fri Jun 27, 2008 10:22 pm
by dbemowsk
I have seen discussion in here about using the SQL date format for date output formatting. People say that it is best to have SQL do the date processing rather than PHP. I have talked to others that say that there are anomalies in the date_format parameters between different flavors of SQL (PostgreSql, MS-SQL, MySQL, etc...). If this is the case and you are trying to code a universal application using the PEAR DB or MDB2 abstraction layers that could be used on any of the supported databases, wouldn't this cause compatibility issues? Wouldn't the PHP date function be better in that case?

Re: Coding using SQL date_format

Posted: Mon Jun 30, 2008 9:21 am
by jaoudestudios
I use time() from php functions.

It generates a unix timestamp from 1970 in seconds. It is very easy to work with, add, subtract etc. Even within mysql it can do calculations i.e add 1 year.


$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);