Re: Date Function in Php
| From: | Miguel Cruz | Date: | Wed, 15 May 2002 19:33:51 +0000 |
| Subject: | Re: Date Function in Php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97791@lists.php.net to get a copy of this message | ||
On Wed, 15 May 2002, Vinod Palan wrote:
> Do any one have date functions like that we have in asp 1) Dateadd()
> 2) Datediff()
> etc?
You might be able to get what you need with strtotime, which is a
marvelous thing. See:
http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html
The rest of the time, I usually pass dates off to MySQL for math. You
don't need to be doing any database transactions; you can just take
advantage of its date functions by sending in constants:
select date_add("2002-05-14 15:44:21", interval 1 day);
Write a function wrapper for the mysql_query() and mysql_result() and then
it's as easy to use as strtotime or anything else.
miguel