Dennis W. Ruffner, Programmer, PHP, MySQL, ODBC, perl, VB for Access

   September 05, 2010
12:25 a.m.
  
dateFuns.inc -- Function giving the number of days until a given date
<?php
///////////////////////////////////////////////////
// Dennis W. Ruffner
// December 2006
// (include directory) /dateFuns.inc
// date functions include
//
// input paramater $DateUntil must be YYYY-MM-DD
//
// to call this function
// include $PATH . '/(include directory)/dateFuns.inc';
// $DateUntil = "2008-11-4";
// $returnDaysDiff = gimmeDaysUntil($DateUntil);
///////////////////////////////////////////////////
function gimmeDaysUntil($DateUntil) {

// set at midnight
   $DateUntil = $DateUntil . " 00:00";
   $untilTimeStamp = strtotime("$DateUntil");
   $today_date = date(Y) . "-" . date(m) . "-" . date(d) . " 00:00";
   $todayTimeStamp = strtotime("$today_date");
   $secondsDiff = $untilTimeStamp - $todayTimeStamp;
   $secondsInDay = 60*60*24;
   $daysDifference = $secondsDiff / $secondsInDay;
   return $daysDifference;

} // end gimmeDaysUntil

?>

This page has been visited 1475 times.