-2

I have a pretty basic question.

I have data formatted in this way:

2018-10-30 00:00:00 UTC

and need to convert it to be

2018-10-30

How do I do that?

Claudiu Papasteri
  • 2,469
  • 1
  • 17
  • 30
AJ Jebelli
  • 101
  • 6
  • 2
    Maybe look at the docs for whatever you're using to obtain that object (POSIXct?) to see how to convert it. Have you tried anything already? – camille Jan 15 '22 at 16:29

1 Answers1

0

Just use as.Date, the format you want is ISO 8601 that is default:

date <- "2018-10-30 00:00:00 UTC"

as.Date(date, tz = "UTC")
#> [1] "2018-10-30"

Created on 2022-01-15 by the reprex package (v2.0.1)

Claudiu Papasteri
  • 2,469
  • 1
  • 17
  • 30