Revision: 41014
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 10, 2011 21:50 by aamirrajpoot
Initial Code
function week_start_date($wk_num, $yr, $first = 1, $format = 'l, d-M-y') { $wk_ts = strtotime('+' . $wk_num . ' weeks', strtotime($yr . '0101')); $mon_ts = strtotime('-' . date('w', $wk_ts) + $first . ' days', $wk_ts); return date($format, $mon_ts); } function date_get_week_start($date, $date_format = "Y-m-d") { /* * Week Start from Monday */ $year = date('Y', strtotime($date)); $week = date('W', strtotime($date)); $date = week_start_date($week, $year, 1, $date_format); return $date; } function date_get_week_end($date, $date_format = "Y-m-d") { /* * Week Ends on Sunday */ $year = date('Y', strtotime($date)); $week = date('W', strtotime($date)); $date = week_start_date($week, $year, 7, $date_format); return $date; } function date_get_month_start($date, $date_format = "Y-m-d") { $year = date('Y', strtotime($date)); $month = date('m', strtotime($date)); $date = $year."-".$month."-"."01"; return date($date_format, strtotime($date)); } function date_get_month_end($date, $date_format = "Y-m-d") { $year = date('Y', strtotime($date)); $month = date('m', strtotime($date)); return date($date_format,strtotime('-1 second',strtotime('+1 month',strtotime($month.'/01/'.$year.' 00:00:00')))); } function date_get_year_start($date, $date_format = "Y-m-d") { $year = date('Y', strtotime($date)); $date = $year."-01-01"; return date($date_format, strtotime($date)); } function date_get_year_end($date, $date_format = "Y-m-d") { $year = date('Y', strtotime($date)); $date = $year."-12-31"; return date($date_format, strtotime($date)); }
Initial URL
Initial Description
These are some date functions. Get Current Week Start Date Get Current Week End Date Get Current Month Start Get Current Month End Get Current Year Start Get Current Year End and these functions can help you getting last week's start date or next month end date. To get last week's start date, remove 7 days from current week, and pass that date to get current week start date and it will return last week's start date.
Initial Title
Some Date Functions
Initial Tags
date
Initial Language
PHP