Skip to content
Sheetwrite

@sheetwrite/core/codec

dateToSerialfunction

Report a problem

On this page

Convert a real UTC Date to the Excel 1900-system serial. It is the inverse of serialToDate except for synthetic serial 60, which JavaScript cannot represent as a Date. Construct calendar dates with Date.UTC(...) (or via parseDateInput) to avoid host-timezone shifts.

Declaration

function dateToSerial(date: Date): number

Parameters

date: Daterequired

The moment to convert, read in UTC.

Returns

number

The serial: 1 is 1900-01-01, and the fraction is the time of day.