Uncategorized
PHP Get monday, sunday, last monday & last sunday
A function I’ve put togheter for a work-related project to get date of monday, sunday, last monday & last sunday.. Might add in next monday and sunday later.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
/** * Get Mondays and Sundays * * Get monday, sunday, last monday & last sunday * Example usage: * * * @param date $offset Provide a date from where to calculate from in strtotime() translatable format. If none is given, today’s date will be used. * * @return array * */ function getMondaysAndSundays($offset=false) { if(!$offset) $offset = strtotime(date(’Y-m-d’)); // this week if(date(’w',$offset) == 6) // last week if(date(’w') == 6) return $mas; |

Posted in