function &getTimeStart($offset = 0, $issunday = true, $now = "") { $offset = (double) $offset; $now = (int) $now; if (empty($now)) { $now = mktime(); } /* ------------------------------------------------------------------------------------------------ */ // Determine GMT Time (UTC+00:00) // Determine this minute, this hour, this day, this month, this year // Don't use strftime() $minute = (int) gmstrftime("%M", $now); $hour = (int) gmstrftime("%H", $now); $day = (int) gmstrftime("%d", $now); $month = (int) gmstrftime("%m", $now); $year = (int) gmstrftime("%Y", $now); // Determine Starting GMT Time and Local Time of Today $daystart = gmmktime(0, 0, 0, $month, $day, $year); $local_daystart = modVisitCounterDateTime::localTimeStart($daystart, $offset, "day"); // Determine Starting GMT Time and Local Time of Yesterday // $yesterdaystart = strtotime( "-1 day", $daystart ) ; $yesterdaystart = $daystart - 86400; $local_yesterdaystart = $local_daystart - 86400; // Determine Starting GMT Time and Local Time of This Week // If Sunday is starting day of week then Sunday = 0 ... Saturday = 6 // If Monday is starting day of week then Monday = 0 ... Sunday = 6 $weekday = (int) strftime("%w", $now); if (!$issunday) { if ($weekday) { $weekday--; } else { $weekday = 6; } } $weekstart = $daystart - $weekday * 86400; $local_weekstart = modVisitCounterDateTime::localTimeStart($weekstart, $offset, "week"); // Starting Starting GMT Time and Local Time of Last Week $lweekstart = $weekstart - 7 * 86400; $local_lweekstart = $local_weekstart - 7 * 86400; // Determine Starting GMT Time and Local Time of This Month $monthstart = gmmktime(0, 0, 0, $month, 1, $year); $local_monthstart = modVisitCounterDateTime::localTimeStart($monthstart, $offset, "month"); // Determine Starting GMT Time and Local Time of Last Month // $days_lmonth: Number days of last month (28/29, 30 or 31) $days_lmonth = (int) strftime("%d", $monthstart - 86400); $lmonthstart = $monthstart - $days_lmonth * 86400; $local_lmonthstart = $local_monthstart - $days_lmonth * 86400; $datetime = array(); $datetime["daystart"] = $daystart; $datetime["local_daystart"] = $local_daystart; $datetime["yesterdaystart"] = $yesterdaystart; $datetime["local_yesterdaystart"] = $local_yesterdaystart; $datetime["weekstart"] = $weekstart; $datetime["local_weekstart"] = $local_weekstart; $datetime["lweekstart"] = $lweekstart; $datetime["local_lweekstart"] = $local_lweekstart; $datetime["monthstart"] = $monthstart; $datetime["local_monthstart"] = $local_monthstart; $datetime["lmonthstart"] = $lmonthstart; $datetime["local_lmonthstart"] = $local_lmonthstart; return $datetime; }