asDatePOSIXct: Conversion from POSIXct to Date

View source: R/asDatePOSIXct.R

asDatePOSIXctR Documentation

Conversion from POSIXct to Date

Description

Conversion from POSIXct to Date

Usage

asDatePOSIXct(x, tz = "")

Arguments

x

A POSIXct vector

tz

An optional timezone string

Details

This function provides a direct conversion from POSIXct to Date. As of R-3.5.1, conversion from POSIXct to Date creates an intermediate POSIXlt object. This intermediate POSIXlt object uses a non-trivial amount of memory. The direct conversion is more memory efficient, and therefore approximately twice as fast as the current solution in base R.

Value

A vector of Date objects

Author(s)

Joshua Ulrich

Examples

p <- .POSIXct(1540181413, "America/Chicago")
as.Date(p)                     # Using UTC timezone
as.Date(p, "America/Chicago")  # Using local timezone
asDatePOSIXct(p)               # Direct, using local timezone

RApiDatetime documentation built on Jan. 14, 2023, 5:06 p.m.