Thanks alot .
I appreciate the group cooperation.
Thanks to wade, James and all friends!
Be Happy!

James Keeline <[EMAIL PROTECTED]> wrote:
--- ziajea <[EMAIL PROTECTED]> wrote:
> 
> Kindly tell me how to find out difference (in days) between two dates 
> in PHP/MYSQL.
> Kindly write the exact line of code in PHP.
> Waiting for early response!
> Thanks!

Your query is a bit vague and this explains why you have had to ask twice in a
single day.

Which is it?  PHP or MySQL?  Different techniques would apply to each.

Are the dates after 1 Jan 1970?  PHP's date functions work best from this point
forward.

What format are the dates in?

One technique involves turning the two dates into a number of seconds since the
epoch date (1 Jan 1970 on Unix/Linux/OS X systems, 1 Jan 1980 on Windows). 
Find the difference.  Divide by the number of seconds in a day.

$d2 = "17 March 2005";
$d1 = "1 January 2003";
print floor((strtotime($d2) - strtotime($d1)) / (24*3600));

This code will only work for dates on or after 1 Jan 1970.

James
_____


James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester Begins Jan 31 -- New Classes Start Every Few Weeks.


Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 


Yahoo! Groups SponsorADVERTISEMENT


---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
  
   To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


                
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 

[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to