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 simplest way to get the day part 2011-08-10
from it, and making sure this day is a proper date and not a string?
Using lubridate::day(timestamp)
obviously fails here.
This would probably be the simplest way:
date(timestamp)
It will return a date class and not a string.
使用日期代替日期
lubridate::date(timestamp)
There is also data.table
s as.IDate()
function now:
timestamp <- "2011-08-10 14:00:00"
data.table::as.IDate(timestamp)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.