Skip to contents

Convert dates to JavaScript timestamps

Usage

format_date(x)

Arguments

x

Date(s) to use in JavaScript: a Date, a POSIXct or a character (e.g. "2020-01-06" or "2020-01-06 12:00:00"). Character strings are interpreted in UTC, which is the time zone used by default by ApexCharts to display datetime axes.

Value

A numeric vector: number of milliseconds since epoch (UTC).

Examples

format_date("2020-01-06")
#> [1] 1.578269e+12
format_date(as.Date("2020-01-06"))
#> [1] 1.578269e+12
format_date(as.POSIXct("2020-01-06 12:00:00", tz = "Europe/Paris"))
#> [1] 1.578308e+12