Jump to content

[SOLVED] date() question


ballhogjoni

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.