time_conv: Convert time between UNIX and epoch formats

Description Usage Arguments Value Author(s) Examples

Description

Conversion between EPOCH and UNIX formats.

Usage

1
2
epoch_to_unix(epoch, date, tz = "UTC")
unix_to_epoch(unix, origin = "1970-01-01", tz = "UTC", returnChar = TRUE)

Arguments

epoch

[character] Character string of the date in EPOCH format. The only accepted formats are "%Y-%m-%d %H:%M:%S" or "%H:%M:%S"

date

[character] If epoch is given in "%H:%M:%S" format, date in format "%Y-%m-%d" can be provided.

unix

[numeric] Time or date in unix format.

origin

[character] For unix_to_epoch, the date of reference in format "%Y-%m-%d". [Default: "1970-01-01"]

tz

[character] Time zone. [Default: "UTC"]

returnChar

[boolean] If TRUE [default], then the epoch format is returned as a character string. In other case, it is returned as POSIX class.

Value

epoch_to_unix return a numeric (UNIX format). unix_to_epoch returns a character or POSIXct (EPOCH format).

Author(s)

Víctor Moreno-González <vmorg@unileon.es>

Examples

1
2
3
4
5
6
7
# Epoch to unix conversion
epoch_to_unix(epoch = "2020-04-13 13:11:00")
epoch_to_unix{epoch = "13:11:00", date = "2020-04-13"}

# Unix to epoch conversion
unix_to_epoch(1586783460, returnChar = T)
unix_to_epoch(1586783460, returnChar = F)

vmoreg00/projects documentation built on April 14, 2020, 4:02 p.m.