[PHP] date difference
Hello, Is there a function to determine the difference between two dates? I am asking so I can do some date verification for COPA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Difference Errors
I have a function that I use to return the number of days between two dates. It worked fine on my Mandrake 7.0 server running PHP 4. I am trying to run it on a RedHat 8.0 box with the same version of PHP. On Mandrake, strtotime() and mktime() returned a negative number for dates prior to 1970-01-01. On the RH 8 box, they both return -1. Is there any work around to calculating date differences for dates prior to 1970? Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Difference Errors
On Thursday 06 February 2003 23:13, Rob Quenzer wrote: I have a function that I use to return the number of days between two dates. It worked fine on my Mandrake 7.0 server running PHP 4. I am trying to run it on a RedHat 8.0 box with the same version of PHP. On Mandrake, strtotime() and mktime() returned a negative number for dates prior to 1970-01-01. On the RH 8 box, they both return -1. Is there any work around to calculating date differences for dates prior to 1970? Have a look at the functions in manual 'Calendar functions'. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Victory uber allies! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date difference
Dear Friends, I am accessing a MySQL database through PHP. I have to calculate the difference between todays date and the date obtained from MySQL database. The Database string is in the form of \"-mm-dd\". I have to convert the above string into unix timestamp so that i can calcualte the difference between the two time stamps. Please help me in this regard. Thanking you, B. Raveendra Reddy National Law School of India University -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date difference
Lots of ways to do it, here's one. Convert them both to unix timestamps and subtract. $nowstamp=mktime() ; $result=mysql_query(SELECT UNIX_TIMESTAMP(mydatefield) AS dbdate FROM mydatabase); $row=mysql_fetch_array($result); $dbdate=$row["dbdate"]; $thedifference=$nowstamp - $dbdate; //above gives you the difference in seconds. $daydifference = intval($thedifference / 86400); // 86400 is number of seconds in a day // intval because I don't want partial days, just number of days // $daydifference above gives you the difference in days kind regards, bill [EMAIL PROTECTED] wrote: Dear Friends, I am accessing a MySQL database through PHP. I have to calculate the difference between todays date and the date obtained from MySQL database. The Database string is in the form of \"-mm-dd\". I have to convert the above string into unix timestamp so that i can calcualte the difference between the two time stamps. Please help me in this regard. Thanking you, B. Raveendra Reddy National Law School of India University -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date difference
On Sat, 31 Mar 2001 20:07:10 +0600, ([EMAIL PROTECTED]) wrote: Dear Friends, I am accessing a MySQL database through PHP. I have to calculate the difference between todays date and the date obtained from MySQL database. select to_days(curdate())-to_days(datefield) from table; - Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]