You are here

function date_days_in_month in Date 7

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.3 date_api/date_api.module \date_days_in_month()
  5. 7.2 date_api/date_api.module \date_days_in_month()

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

3 calls to date_days_in_month()
DateAPITestCase::testDateAPI in tests/date_api.test
DateObject::forceValid in date_api/date_api.module
Convert 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 datetime value out of an incomplete array of selected values.

File

date_api/date_api.module, line 1329
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

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);
  return $date
    ->format('t');
}