The easiest way to retrieve a date from a timestamp

Consider the following timestamp

timestamp <- ymd_hms("2011-08-10 14:00:00", tz = "Pacific/Auckland")

> timestamp
[1] "2011-08-10 14:00:00 NZST"

What is the easiest way to get part of the day from him 2011-08-10and make sure that this day is the correct date, not a string?

Using lubridate::day(timestamp)here is clearly not working.

+9
source share
2 answers

This will probably be the easiest way:

date(timestamp)

It will return a date class, not a string.

+7
source

Use date instead of day

lubridate::date(timestamp)
0
source

Source: https://habr.com/ru/post/1658713/


All Articles