Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
Date difference
Old
  (#1)
PHP Newbie
Guest
 
Posts: n/a
Default Date difference - 05-14-2007, 02:50 AM

How can I tell the number of days between a date variable and today?
For example, is there something like:

var nDays = dDateVariable - now();

?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Date difference
Old
  (#2)
Ehsan
Guest
 
Posts: n/a
Default Re: Date difference - 05-14-2007, 02:51 AM

Try this:

<?php
$startDate = "2006-05-01";
$endDate = date("Y-m-d");

$diffInSec = strtotime($endDate) - strtotime($startDate);
$diffInDays = $diffInSec/60/60/24;

echo $diffInDays;
?>

Hope this helps.

Thanks and God Bless!!

Ehsan
http://ehsan.bdwebwork.com

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top