Tuesday, April 05, 2011

PHP Date functions for Reports

Needed to pre-populate some datepickers, and it took me a while to remember how.

#common date functions for reporting
function getFirstDayOfMonth() {
  return date("Y-m-01");
}
function getLastDayOfMonth() {
  return date("Y-m-t");
}
function getLastDayofLastMonth() {
  return date("Y-m-t", strtotime('-1 month',time()));
}
function getFirstDayofLastMonth() {
  return date("Y-m-01", strtotime('-1 month',time()));
}

No comments: