Jump to content

How to handle the dates greater than "2057-12-31"


jeeva

Recommended Posts

try[code]<?php
function in_day($a){
$monts=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
$a = explode('-',$a);
if (($a[0] % 400 == 0) or ($a[0] % 4 == 0 and $a[0] % 100 != 0))  $monts[2] = 29;
$y = $a[0] -1;
$out = $y *365 + (int) ($y / 4) - (int) ($y / 100) + (int) ($y / 400);
for ($i=0;$i<$a[1];$i++) $out += $monts[$i];
$out += $a[2] - 1;
return $out;
}

$date1='2045-12-31';
$date2='2047-12-31';
echo in_day($date2) - in_day($date1);

?>[/code]
Hi jeeva try this one,

it will help u


<?php
function in_day($a){
$monts=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
$a = explode('-',$a);
if (($a[0] % 400 == 0) or ($a[0] % 4 == 0 and $a[0] % 100 != 0))  $monts[2] = 29;
$y = $a[0] -1;
$noOfDays = $y *365 + (int) ($y / 4) - (int) ($y / 100) + (int) ($y / 400);
for ($i=0;$i<$a[1];$i++) $noOfDays += $monts[$i];
$noOfDays += $a[2] - 1;
return $noOfDays;
}

$date1='2045-12-31';
$date2='2047-12-31';
echo in_day($date2) - in_day($date1);

?>

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.