php - Unable to resolve leap seconds miscalculation on calendar -


i have calendar showing me wrong days of date day of week. more specifically, 1 day behind actual date.

i've done bunch of research , used following question (php date('d') calculates same output 2 consecutive days) can't work on script.

it's displaying 26th of october twice, there on dates go wrong.

$firstday = mktime(0,0,0,$month,1,$year); $day = date('y-m-d',$firstday); $fday = strtotime($day." last sunday ",$firstday); $currday_timestamp = mktime(0,0,0,date('m'),date('d'),date('y'));  for($i=0;$i<7;$i++) {             $firstweek[$i]['id'] = date("y-m-d",$fday+(86400 * $i));             $firstweek[$i]['val'] = date("d",$fday+(86400 * $i));             if($currday_timestamp > $fday+(86400 * $i)) {                 $firstweek[$i]['flag'] = 1;                 }             $secondweek[$i]['id'] = date("y-m-d",$fday+(86400 * ($i+7)));             $secondweek[$i]['val'] = date("d",$fday+(86400 * ($i+7)));             if($currday_timestamp > $fday+(86400 * ($i+7))) {                 $secondweek[$i]['flag'] = 1;                 }             $thirdweek[$i]['id'] = date("y-m-d",$fday+(86400 * ($i+14)));             $thirdweek[$i]['val'] = date("d",$fday+(86400 * ($i+14)));             if($currday_timestamp > $fday+(86400 * ($i+14))) {                 $thirdweek[$i]['flag'] = 1;                 }             $fourthweek[$i]['id'] = date("y-m-d",$fday+(86400 * ($i+21)));             $fourthweek[$i]['val'] = date("d",$fday+(86400 * ($i+21)));             if($currday_timestamp > $fday+(86400 * ($i+21))) {                 $fourthweek[$i]['flag'] = 1;                 }             $fifthweek[$i]['id'] = date("y-m-d",$fday+(86400 * ($i+28)));             $fifthweek[$i]['val'] = date("d",$fday+(86400 * ($i+28)));             if($currday_timestamp > $fday+(86400 * ($i+28))) {                 $fifthweek[$i]['flag'] = 1;                 }             $sixthweek[$i]['id'] = date("y-m-d",$fday+(86400 * ($i+35)));             $sixthweek[$i]['val'] = date("d",$fday+(86400 * ($i+35)));             if($currday_timestamp > $fday+(86400 * ($i+35))) {                 $sixthweek[$i]['flag'] = 1;                 }         } 

how go tackling leap seconds problem? there value need add seconds?

sounds change daylight saving time standard time.

simplest way add couple of hours base time:

$time_offset = 2 * 60 * 60; // 2 hours $firstday = mktime(0,0,0,$month,1,$year) + $time_offset; $day = date('y-m-d',$firstday); $fday = strtotime($day." last sunday ",$firstday) + $time_offset; $currday_timestamp = mktime(0,0,0,date('m'),date('d'),date('y')) + $time_offset; 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -