Constants

CALENDAR_WINDOWS_1900

CALENDAR_WINDOWS_1900 = 1900

constants

CALENDAR_MAC_1904

CALENDAR_MAC_1904 = 1904

Properties

$monthNames

$monthNames : array<mixed,string>

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

Type

array<mixed,string>

$numberSuffixes

$numberSuffixes : array<mixed,string>

Type

array<mixed,string>

$excelCalendar

$excelCalendar : integer

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

Type

integer

$defaultTimeZone

$defaultTimeZone : null|\DateTimeZone

Default timezone to use for DateTime objects.

Type

null|\DateTimeZone

$possibleDateFormatCharacters

$possibleDateFormatCharacters : 

Type

Methods

setExcelCalendar()

setExcelCalendar(integer  $baseDate) : boolean

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

Parameters

integer $baseDate

Excel base date (1900 or 1904)

Returns

boolean —

Success or failure

getExcelCalendar()

getExcelCalendar() : integer

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

Returns

integer —

Excel base date (1900 or 1904)

setDefaultTimezone()

setDefaultTimezone(\DateTimeZone|string  $timeZone) : boolean

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

boolean —

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|integer  $excelTimestamp, null|\DateTimeZone|string  $timeZone = null) : \DateTime

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

Parameters

float|integer $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|integer  $excelTimestamp, null|\DateTimeZone|string  $timeZone = null) : integer

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

Parameters

float|integer $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

integer —

Unix timetamp for this date/time

PHPToExcel()

PHPToExcel(mixed  $dateValue) : boolean|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

boolean|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(integer  $dateValue) : float

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

Parameters

integer $dateValue

Unix Timestamp

Returns

float —

MS Excel serialized date/time value

formattedPHPToExcel()

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

formattedPHPToExcel.

Parameters

integer $year
integer $month
integer $day
integer $hours
integer $minutes
integer $seconds

Returns

float —

Excel date/time value

isDateTime()

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

Is a given cell a date/time?

Parameters

\PhpOffice\PhpSpreadsheet\Cell\Cell $pCell

Returns

boolean

isDateTimeFormat()

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

Is a given number format a date/time?

Parameters

\PhpOffice\PhpSpreadsheet\Style\NumberFormat $pFormat

Returns

boolean

isDateTimeFormatCode()

isDateTimeFormatCode(string  $pFormatCode) : boolean

Is a given number format code a date/time?

Parameters

string $pFormatCode

Returns

boolean

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) : integer|string

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

Parameters

string $month

Month name or abbreviation

Returns

integer|string —

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

dayStringToNumber()

dayStringToNumber(string  $day) : integer|string

Strips an ordinal from a numeric value.

Parameters

string $day

Day number with an ordinal

Returns

integer|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