date_num: date to number

View source: R/date_funcs.R

date_numR Documentation

date to number

Description

It converts date to numeric value in specified unit.

Usage

date_num(x, unit = "s", origin = "1970-01-01", scientific = FALSE)

Arguments

x

date.

unit

time unit, available values including milliseconds, seconds, minutes, hours, days, weeks.

origin

original date, defaults to 1970-01-01.

scientific

logical, whether to encode the number in scientific format, defaults to FALSE.

Examples

# setting unit
date_num(Sys.time(), unit='milliseconds')
date_num(Sys.time(), unit='mil')

date_num(Sys.time(), unit='seconds')
date_num(Sys.time(), unit='s')

date_num(Sys.time(), unit='days')
date_num(Sys.time(), unit='d')

# setting origin
date_num(Sys.time(), unit='d', origin = '1970-01-01')
date_num(Sys.time(), unit='d', origin = '2022-01-01')

# setting scientific format
date_num(Sys.time(), unit='mil', scientific = FALSE)
date_num(Sys.time(), unit='mil', scientific = TRUE)
date_num(Sys.time(), unit='mil', scientific = NULL)


xefun documentation built on Aug. 10, 2023, 5:07 p.m.