<?php
$currDate = date('Y-m-d h:i:s');
// convert timestamp from mysql
$nextReviewDt = date('F d, Y',strtotime($nextReviewDt));
// Add 30 days
$CommentStartDt = date('m/d/Y');
$CommentEndDt = date('m/d/Y',
mktime(0,0,0,date("m"),date("d")+30,date("Y"))); // add 30 days
// convert year to 4 digits
if ($y > 60) $y = '19'.$y;
else $y = '20'.$y;
// split if there are slash or dash
list($m, $d, $y) = split('[/|-]', $iDate);
if (preg_match("/-/", $iDate))
list($m, $d, $y) = split('-', $iDate);
else if (preg_match("/\//", $iDate))
list($m, $d, $y) = split('/', $iDate);
$specDate = mktime(0, 0, 0, $m, $d, $y);
$numOfDays = (time() - $specDate) / (24 * 60 * 60);
// convert date from mysql db
if (preg_match("/(.*)Dt$/", $dbDate))
$dbDate = date("M d, Y h:ia", strtotime($dbDate));
// output dates - walk the days
$startDt = '2009-01-04';
$endDt = date('Y-m-d');
while ($startDt != $endDt)
{
echo "$startDt <br/>";
// increment the day
$startDt = strtotime(date("Y-m-d", strtotime($startDt)) . " +1 day");
// convert back to readable format
$startDt = date("Y-m-d",$startDt);
}
function count_days( $a, $b )
{
// First we need to break these dates into their constituent parts:
$gd_a = getdate( $a );
$gd_b = getdate( $b );
// Now recreate these timestamps, based upon noon on each day
// The specific time doesn't matter but it must be the same each day
$a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] );
$b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] );
// Subtract these two numbers and divide by the number of seconds in a
// day. Round the result since crossing over a daylight savings time
// barrier will cause this time to be off by an hour or two.
return round( abs( $a_new - $b_new ) / 86400 );
}
0 Comments