Tuesday, December 15, 2009

First date and last date of month PHP

// for current month
$start_date = date("Y-m-d", strtotime(date('Y-m').'-01 00:00:00'));
$end_date = date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime(date('Y-m').'-01 00:00:00'))));


// for specific month
$start_date = date("Y-m-d", strtotime(date('Y').'-'.$month.'-01 00:00:00'));
$end_date = date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime(date('Y').'-'.$month.'-01 00:00:00'))));

No comments:

Post a Comment