Constants

CALENDAR_WINDOWS_1900

CALENDAR_WINDOWS_1900 = 1900

constants

CALENDAR_MAC_1904

CALENDAR_MAC_1904 = 1904

Properties

$monthNames

$monthNames : string[]

Names of the months of the year, indexed by shortname Planned usage for locale settings.

Type

string[]

$numberSuffixes

$numberSuffixes : string[]

Type

string[]

$excelCalendar

$excelCalendar : int

Base calendar year to use for calculations Value is either CALENDAR_WINDOWS_1900 (1900) or CALENDAR_MAC_1904 (1904).

Type

int

$defaultTimeZone

$defaultTimeZone : null|\DateTimeZone

Default timezone to use for DateTime objects.

Type

DateTimeZone

$possibleDateFormatCharacters

$possibleDateFormatCharacters

Methods

setExcelCalendar()

setExcelCalendar(int  $baseDate) : bool

Set the Excel calendar (Windows 1900 or Mac 1904).

Parameters

int $baseDate

Excel base date (1900 or 1904)

Returns

bool —

Success or failure

getExcelCalendar()

getExcelCalendar() : int

Return the Excel calendar (Windows 1900 or Mac 1904).

Returns

int —

Excel base date (1900 or 1904)

setDefaultTimezone()

setDefaultTimezone(\DateTimeZone|string  $timeZone) : bool

Set the Default timezone to use for dates.

Parameters

\DateTimeZone|string $timeZone

The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions

Returns

bool —

Success or failure

getDefaultTimezone()

getDefaultTimezone() : \DateTimeZone

Return the Default timezone being used for dates.

Returns

\DateTimeZone —

The timezone being used as default for Excel timestamp to PHP DateTime object

excelToDateTimeObject()

excelToDateTimeObject(float|int  $excelTimestamp, null|\DateTimeZone|string  $timeZone = null) : \DateTime

Convert a MS serialized datetime value from Excel to a PHP Date/Time object.

Parameters

float|int $excelTimestamp

MS Excel serialized date/time value

null|\DateTimeZone|string $timeZone

The timezone to assume for the Excel timestamp, if you don't want to treat it as a UTC value Use the default (UST) unless you absolutely need a conversion

Returns

\DateTime —

PHP date/time object

excelToTimestamp()

excelToTimestamp(float|int  $excelTimestamp, null|\DateTimeZone|string  $timeZone = null) : int

Convert a MS serialized datetime value from Excel to a unix timestamp.

Parameters

float|int $excelTimestamp

MS Excel serialized date/time value

null|\DateTimeZone|string $timeZone

The timezone to assume for the Excel timestamp, if you don't want to treat it as a UTC value Use the default (UST) unless you absolutely need a conversion

Returns

int —

Unix timetamp for this date/time

PHPToExcel()

PHPToExcel(mixed  $dateValue) : bool|float

Convert a date from PHP to an MS Excel serialized date/time value.

Parameters

mixed $dateValue

Unix Timestamp or PHP DateTime object or a string

Returns

bool|float —

Excel date/time value or boolean FALSE on failure

dateTimeToExcel()

dateTimeToExcel(\DateTimeInterface  $dateValue) : float

Convert a PHP DateTime object to an MS Excel serialized date/time value.

Parameters

\DateTimeInterface $dateValue

PHP DateTime object

Returns

float —

MS Excel serialized date/time value

timestampToExcel()

timestampToExcel(int  $dateValue) : float

Convert a Unix timestamp to an MS Excel serialized date/time value.

Parameters

int $dateValue

Unix Timestamp

Returns

float —

MS Excel serialized date/time value

formattedPHPToExcel()

formattedPHPToExcel(int  $year, int  $month, int  $day, int  $hours, int  $minutes, int  $seconds) : float

formattedPHPToExcel.

Parameters

int $year
int $month
int $day
int $hours
int $minutes
int $seconds

Returns

float —

Excel date/time value

isDateTime()

isDateTime(\PhpOffice\PhpSpreadsheet\Cell\Cell  $pCell) : bool

Is a given cell a date/time?

Parameters

\PhpOffice\PhpSpreadsheet\Cell\Cell $pCell

Returns

bool —

isDateTimeFormat()

isDateTimeFormat(\PhpOffice\PhpSpreadsheet\Style\NumberFormat  $pFormat) : bool

Is a given number format a date/time?

Parameters

\PhpOffice\PhpSpreadsheet\Style\NumberFormat $pFormat

Returns

bool —

isDateTimeFormatCode()

isDateTimeFormatCode(string  $pFormatCode) : bool

Is a given number format code a date/time?

Parameters

string $pFormatCode

Returns

bool —

stringToExcel()

stringToExcel(string  $dateValue) : false|float

Convert a date/time string to Excel time.

Parameters

string $dateValue

Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'

Returns

false|float —

Excel date/time serial value

monthStringToNumber()

monthStringToNumber(string  $month) : int|string

Converts a month name (either a long or a short name) to a month number.

Parameters

string $month

Month name or abbreviation

Returns

int|string —

Month number (1 - 12), or the original string argument if it isn't a valid month name

dayStringToNumber()

dayStringToNumber(string  $day) : int|string

Strips an ordinal from a numeric value.

Parameters

string $day

Day number with an ordinal

Returns

int|string —

The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric

validateTimeZone()

validateTimeZone(\DateTimeZone|string  $timeZone) : \DateTimeZone

Validate a timezone.

Parameters

\DateTimeZone|string $timeZone

The timezone to validate, either as a timezone string or object

Returns

\DateTimeZone —

The timezone as a timezone object