date_lang

(PHP 3, PHP 4 )

date_lang -- Format a local time/date with the language you want.
It is a clone of the native date() function, but works with any language !

Description

string date_lang ( string format [, int timestamp])

Returns a string formatted according to the given format string using the given integer timestamp or the current local time if no timestamp is given. In otherwords, timestamp is optional and defaults to the value of time().

You MUST initialise the variables $_SESSION["date_lang"]["language"] and $_SESSION["date_lang"]["lang_dir"] for selecting the language before any call of date_lang fonction.

For example :
$_SESSION["date_lang"]["language"]="fr";
$_SESSION["date_lang"]["lang_dir"]="/var/www/html/langfiles/";
date_lang("d m Y");
date_lang("l",1054115595);
...

Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). On windows this range is limited from 01-01-1970 to 19-01-2038.

To generate a timestamp from a string representation of the date, you may be able to use strtotime(). Additionally, some databases have functions to convert their date formats into timestamps (such as MySQL's UNIX_TIMESTAMP function).

Table 1. The following characters are recognized in the format parameter string

format characterDescriptionExample returned values
aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
BSwatch Internet time000 through 999
dDay of the month, 2 digits with leading zeros01 to 31
DA textual representation of a day, three lettersMon through Sun
FA full textual representation of a month, such as January or MarchJanuary through December
g12-hour format of an hour without leading zeros1 through 12
G24-hour format of an hour without leading zeros0 through 23
h12-hour format of an hour with leading zeros01 through 12
H24-hour format of an hour with leading zeros00 through 23
iMinutes with leading zeros00 to 59
I (capital i)Whether or not the date is in daylights savings time1 if Daylight Savings Time, 0 otherwise.
jDay of the month without leading zeros1 to 31
l (lowercase 'L')A full textual representation of the day of the weekSunday through Saturday
LWhether it's a leap year1 if it is a leap year, 0 otherwise.
mNumeric representation of a month, with leading zeros01 through 12
MA short textual representation of a month, three lettersJan through Dec
nNumeric representation of a month, without leading zeros1 through 12
ODifference to Greenwich time (GMT) in hoursExample: +0200
rRFC 822 formatted dateExample: Thu, 21 Dec 2000 16:01:07 +0200
sSeconds, with leading zeros00 through 59
SEnglish ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
tNumber of days in the given month28 through 31
TTimezone setting of this machineExamples: EST, MDT ...
USeconds since the Unix Epoch (January 1 1970 00:00:00 GMT)See also time()
wNumeric representation of the day of the week0 (for Sunday) through 6 (for Saturday)
WISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)Example: 42 (the 42nd week in the year)
YA full numeric representation of a year, 4 digitsExamples: 1999 or 2003
yA two digit representation of a yearExamples: 99 or 03
zThe day of the year0 through 366
ZTimezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.-43200 through 43200

Unrecognized characters in the format string will be printed as-is.