ID | Project | Category | Submitted / Last Updated |
---|---|---|---|
01568 | UserSpice | ACP Code | 2022-10-07 11:37:10 / 2023-07-22 05:58:18 |
Reported | Dan Hoover | Assigned To | Unassigned |
Priority | none | Reported | 5.4.5 |
Status | closed fixed | Resolution Version and Commit | 5.5.0 |
Summary | Add dateOffset (rename) function | ||
Description |
x function dateOffset($number, $datestring = "", $unit = "days",){ if($datestring == ""){ $datestring = date("Y-m-d"); } $first = substr($number, 0, 1); if($first != "+" && $first != "-"){ $symbol = "+ "; }else{ $symbol = ""; } return date("Y-m-d",strtotime($symbol . $number . $unit,strtotime($datestring))); } So if you just want today you can do echo dateOffset(30); Or you can do 7 days ago with echo dateOffset(-7); Or what the day will be in 17 hours with //can be hours, months, days, years, etc echo dateOffset(17,"","hours"); Or you can do it from another date so 20 days from Jan 1, 2023 echo dateOffset(20,"2023-01-01"); |