Re: [PHP] Re: Calculate No Of Days

2005-01-04 Thread Wouter van Vliet
On Mon, 03 Jan 2005 22:58:49 -0500, Jerry Kita [EMAIL PROTECTED] wrote:
 Khuram Noman wrote:
  Hi
 
  Is there any function avialable in PHP to calculate
  the no of days by passing 2 dates like 1 argument is
  1/1/2005 and the second one is 1/2/2005 then it
  returns the no of days or how can i do that if there
  is no builtin function .
 
  Regards
  Khuram Noman
 

Maybe you can try the pear Date package - it has some handy function
that does exactly what you're asking for:

http://pear.php.net/package/Date/docs/1.4.2/apidoc/Date-1.4.2/Date_Calc.html#methoddateDiff

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



Re: [PHP] Re: Calculate No Of Days

2005-01-04 Thread Jamie Alessio
 Is there any function avialable in PHP to calculate
 the no of days by passing 2 dates

If you happen to be pulling both dates from MySQL you could use the 
MySQL date functions:
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html
http://dev.mysql.com/doc/mysql/en/Date_calculations.html

If that is not possible and you don't/can't use the Pear Date library 
recommended previously you could do date arithmetic using unix 
timestamps. So, take the timestamp of 1/1/2005 and subtract the 
timestamp of 1/2/2004. That will give you the number of seconds between 
the two dates and from there you can figure out how many days are 
between the two.

- Jamie

Hi
Is there any function avialable in PHP to calculate
the no of days by passing 2 dates like 1 argument is
1/1/2005 and the second one is 1/2/2005 then it
returns the no of days or how can i do that if there
is no builtin function .
Regards
Khuram Noman

Maybe you can try the pear Date package - it has some handy function
that does exactly what you're asking for:
http://pear.php.net/package/Date/docs/1.4.2/apidoc/Date-1.4.2/Date_Calc.html#methoddateDiff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Calculate No Of Days

2005-01-03 Thread Jerry Kita
Khuram Noman wrote:
Hi 

Is there any function avialable in PHP to calculate
the no of days by passing 2 dates like 1 argument is
1/1/2005 and the second one is 1/2/2005 then it
returns the no of days or how can i do that if there
is no builtin function .
Regards
Khuram Noman
__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Here's a piece of code that I use on my website. It calculates the 
number of days from today to some future date (which happens to be July 
16, 2005) It's not exactly what you asked for but it might be helpful to 
you. No one will confuse me with being a professional programmer but 
this seems to work well on my site.

snippet 
$timeuntilcamp = mktime(12,0,0,7,16,2005,-1) - time();
$daysuntilcamp = round($timeuntilcamp/86400);
if ($daysuntilcamp  0)
  {
  print h4Days until start of 2005 Camp: .$daysuntilcamp./h4\n;
  }
 snippet
You can see it in action by visiting:
http://www.salkehatchiehuntersville.com/Salkehatchie_2005_Camp.php
--
Jerry Kita
http://www.salkehatchiehuntersville.com
email: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php