Jump to content

Recommended Posts

You could do a loop like so:

 

<?php
$bContinue = true;
$sDate = strtodate("01/01/2008");
$eDate = strtodate("07/22/2008");
$i=0;
while ($eDate > $sDate) {
    $sDate = $sDate + (60*60*24); // one date 
    $i++; 
}

echo $i . " days have passed.";

 

There may be a better way, but that should work.

Link to comment
https://forums.phpfreaks.com/topic/137062-solved-date-question/#findComment-715833
Share on other sites

Not sure if you can use arithmetic like this but:

 

$sub = strtotime(07/22/2008) - strtotime(01/01/2008); //get  timestamp (seconds)
$sub = ($sub/3600) / 24; // get days seconds / 60*60*24 = 1 day
echo int_val($sub); //round to nearest integer

Link to comment
https://forums.phpfreaks.com/topic/137062-solved-date-question/#findComment-715835
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.