PHP: Calendar functions - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<bzwritecal_days_in_month>
view the version of this page
Last updated: Wed, 29 Jan 2003

VI. Calendar functions

이 함수는 PHP 소스코드의 "dl"이나 "ext" 디렉토리에 있는 calender extension을 함께 사용하도록 컴파일하여야 사용가능하다. 사용전에 꼭 README 파일을 읽어보라.

PHP에는 서로 다른 날짜(달력) 형태를 변환시켜 주는 함수들을 제공한다. Julian Day Count가 기본이 된다. 이것은 BC4000년의 어느 시점을 기준으로 잡아 그곳에서부터 얼마의 날짜가 지났는 가를 기준으로 삼는 것이다. 이 Julian Day Count는 일반적으로 사용하는 Julian 시스템과는 다르다는 것을 알아두자. Calendar 시스템에 대해 자세히 알고 싶다면 을 방문하여 보라. 이 설명서중에서는 위의 페이지에서 발췌된 내용을 ""로 둘러 싸고 있다.

차례
cal_days_in_month -- Return the number of days in a month for a given year and calendar
cal_from_jd -- Converts from Julian Day Count to a supported calendar and return extended information
cal_info -- Returns information about a particular calendar
cal_to_jd -- Converts from a supported calendar to Julian Day Count
easter_date --  Get UNIX timestamp for midnight on Easter of a given year
easter_days --  Get number of days after March 21 on which Easter falls for a given year
FrenchToJD --  Converts a date from the French Republican Calendar to a Julian Day Count
GregorianToJD --  Converts a Gregorian date to Julian Day Count
JDDayOfWeek -- Returns the day of the week
JDMonthName -- Returns a month name
JDToFrench --  Converts a Julian Day Count to the French Republican Calendar
JDToGregorian -- Converts Julian Day Count to Gregorian date
JDToJewish --  Converts a Julian Day Count to the Jewish Calendar
JDToJulian --  Converts a Julian Day Count to a Julian Calendar Date
jdtounix -- Convert Julian Day to UNIX timestamp
JewishToJD --  Converts a date in the Jewish Calendar to Julian Day Count
JulianToJD --  Converts a Julian Calendar date to Julian Day Count
unixtojd -- Convert UNIX timestamp to Julian Day


User Contributed Notes
Calendar functions
add a note add a note
ssharma at odc dot net
31-Jan-2000 10:36

If you're interested in dates/calendars, check out the MCAL stuff.

mikebabcock at pobox dot com
17-Jul-2000 04:20

There are two world calculations for the date of Easter.  The Easter date function should account for this; one used (generally) by the Western world and one (generally) used by the Eastern (the official date used by the East Orthodox Church).
kmcm at bigfoot dot com
21-Jan-2002 01:42

if, like me, you don't have a PHP build that includes the cal functions, you may want to use this function for sorting out leap year.

function days_in_feb($year){

//$year must be YYYY
//[gregorian] leap year math :

if ($year < 0) $year++;
$year += 4800;

   if ( ($year % 4) == 0) {
if (($year % 100) == 0) {
   if (($year % 400) == 0) {
return(29);
   } else {
return(28);
  }
} else {
   return(29);
}
   } else {
return(28);
   }
}

of course the next leap year isn't until the end of the century but this makes for timeless code I guess ...or if you are using 2000 in your dates or are going far back in time, etc, it is necessary.

karen at rndassociates dot com
02-Jul-2002 12:58

Find the number of days in a month:

// Month
$m = 2;

// Year
$y = 2000;

// Seed it with 31
$daysinmonth = 31;

while (checkdate($m, $daysinmonth, $y) == false) {
  $daysinmonth -= 1;
}

// Now $daysinmonth equals the correct number of days in the month.

huk at axaron dot com
03-Jul-2002 03:19

function days_in_month ( $monat, $jahr ) {
return 32 - date ("d", mktime (0,0,0,$monat,32,$jahr));
}

gaoweibin at 163 dot net
26-Aug-2002 09:26

This is a Chinese Lunar Calendar, including SolarTerm, TianGan, DiZhi, DiesFaustus and Holidays.


dy64 at dy64 dot de
12-Nov-2002 01:18

Best performance:
/*
* Find the number of days in a month
* Year is between 1 and 32767 inclusive
* Month is between 1 and 12 inclusive
*/
function DayInMonth($month, $year) {
var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if ($month != 2) return $daysInMonth[$month - 1];
return (checkdate($month, 29, $year)) ? 29 : 28;
}

add a note add a note

<bzwritecal_days_in_month>
 Last updated: Wed, 29 Jan 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Thu May 22 21:11:29 2003 CEST