summaryrefslogtreecommitdiffstats
path: root/SchedulerHelperDate.php
diff options
context:
space:
mode:
Diffstat (limited to 'SchedulerHelperDate.php')
-rwxr-xr-xSchedulerHelperDate.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/SchedulerHelperDate.php b/SchedulerHelperDate.php
index 0836997..33635a9 100755
--- a/SchedulerHelperDate.php
+++ b/SchedulerHelperDate.php
@@ -118,4 +118,34 @@ class SchedulerHelperDate
return self::addDate($timestamp, self::$INTERVAL_UNITS["year"], $count);
}
+ static public function weekStart($timestamp, $startOnMonday = true){
+ $shift = self::getDayOfWeek($timestamp);
+ if($startOnMonday){
+ if($shift === 0){
+ $shift = 6;
+ }
+ else{
+ $shift--;
+ }
+ }
+ return self::addDays($timestamp, -1*$shift);
+ }
+
+ static public function monthStart($timestamp){
+ $date = new DateTime();
+ $date->setTimestamp($timestamp);
+ $m = $date->format('m');
+ $y = $date->format('Y');
+ $date->setDate($y, $m, 1);
+ return $date->getTimestamp();
+ }
+
+ static public function yearStart($timestamp){
+ $date = new DateTime();
+ $date->setTimestamp($timestamp);
+ $y = $date->format('Y');
+ $date->setDate($y, 1, 1);
+ return $date->getTimestamp();
+ }
+
} \ No newline at end of file