PHP  
downloads | documentation | faq | getting help | | php.net sites | links 
search for in the  
previousbzwritecal_days_in_monthnext
Last updated: Tue, 28 May 2002
view this page in Printer friendly version | English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Turkish

VI. Calendar functions

Introduction

The calendar extension presents a series of functions to simplify converting between different calendar formats. The intermediary or standard it is based on is the Julian Day Count. The Julian Day Count is a count of days starting from January 1st, 4713 B.C. To convert between calendar systems, you must first convert to Julian Day Count, then to the calendar system of your choice. Julian Day Count is very different from the Julian Calendar! For more information on Julian Day Count, visit . For more information on calendar systems visit . Excerpts from this page are included in these instructions, and are in quotes.

Installation

To get these functions to work, you have to compile PHP with --enable-calendar.

Runtime Configuration

T�m� laajennus ei m��rittele yht�k��n konfigurointi asetusta.

Resource Types

T�m� laajennus ei m��rittele yht�k��n resurssi-tyyppi�.

Predefined Constants

These constants are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

CAL_GREGORIAN (integer)

CAL_JULIAN (integer)

CAL_JEWISH (integer)

CAL_FRENCH (integer)

CAL_NUM_CALS (integer)

CAL_DOW_DAYNO (integer)

CAL_DOW_SHORT (integer)

CAL_DOW_LONG (integer)

CAL_MONTH_GREGORIAN_SHORT (integer)

CAL_MONTH_GREGORIAN_LONG (integer)

CAL_MONTH_JULIAN_SHORT (integer)

CAL_MONTH_JULIAN_LONG (integer)

CAL_MONTH_JEWISH (integer)

CAL_MONTH_FRENCH (integer)

Sis�llys
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 about notes

31-Jan-2000 09:36

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


17-Jul-2000 03: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).


21-Jan-2002 12: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.


24-Jan-2002 08:20

A correction to the manual:
In PHP 4.0.5 and above Calendar, support is built-in. You don't need to
load any additional extensions in order to use these functions. 

Thanks,

Vikas


01-Jul-2002 11: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.


03-Jul-2002 02:19

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

add a note about notes
previousbzwritecal_days_in_monthnext
Last updated: Tue, 28 May 2002
show source | credits | stats | mirror sites:  
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Thu Jul 4 12:06:15 2002 CEST