You are here

function date_days_in_month in Date 7.3

Same name and namespace in other branches
  1. 5.2 date_api.module \date_days_in_month()
  2. 6.2 date_api.module \date_days_in_month()
  3. 6 date_api.module \date_days_in_month()
  4. 7 date_api/date_api.module \date_days_in_month()
  5. 7.2 date_api/date_api.module \date_days_in_month()

Identifies the number of days in a month for a date.

3 calls to date_days_in_month()
DateApiTestCase::testDateApi in date_api/tests/DateApiTestCase.test
Test date_format_date().
DateObject::forceValid in date_api/date_api.module
Converts a date part into something that will produce a valid date.
date_sql_handler::complete_date in date_api/date_api_sql.inc
Create a complete date/time value out of an incomplete array of values.

File

date_api/date_api.module, line 2000
This module will make the date API available to other modules.

Code

function date_days_in_month($year, $month) {

  // Pick a day in the middle of the month to avoid timezone shifts.
  $datetime = date_pad($year, 4) . '-' . date_pad($month) . '-15 00:00:00';
  $date = new DateObject($datetime);
  if ($date->errors) {
    return FALSE;
  }
  else {
    return $date
      ->format('t');
  }
}