Skip to content

Function: formatDate() ​

ts
function formatDate(ms): string | undefined;

Experimental

Format milliseconds since the epoch as the shortest ISO-style UTC string that parseDate reads back to the same value, Plotly-style: 2024-03-01, 2024-03-01 12:30, 2024-03-01 12:30:05, 2024-03-01 12:30:05.25.

Parameters ​

ParameterTypeDescription
msnumberMilliseconds since the epoch; rounded to a whole millisecond.

Returns ​

string | undefined

The formatted date, or undefined for non-finite values and years outside -9999…9999 (which ISO strings here cannot express).

Released under the MIT License.