Following is the function which I have created for getting sunday as a starting day of a week,
function getCurrentIntervalOfWeek($liveratetime) {
// get start of each week.
$dayofweek = date('w', $liveratetime);
$getdate = date('Y-m-d', $liveratetime);
$createstart = strtotime('last Sunday', $getdate);
$weekstart = ($dayofweek == 0) ? $liveratetime : $createstart;
// get the current time interval for a week, i.e. Sunday 00:00:00 UTC
$currentInterval = mktime(0,0,0, date('m', $weekstart), date('d', $weekstart), date('Y', $weekstart));
return $currentInterval;
}
Here liveratetime is the epoch time of any day in a week. Basically this function takes the liveratetime and looks for last sunday so as to get the current interval for that perticulat liveratetime epoch.
but the issue here is that, whenever I try to get current interval from this for certain liveratetime the
$createstart = strtotime('last Sunday', $getdate);
gives me -345600
. And I am not getting why? can anyone please share a light on this.
This usually happens on the past dates like
2007-10-02
strtotime
. – Soporific