Reputation: 4040
Given a date-time:
"Tue May 01 23:02:50 GMT+03:00 2018"
How can I transfer it to normal ddmmyyyy hh:mm:ss format?
I have tried as.date
- got NA
.
Tried with parse_date_time
- same result.
Please advise.
Upvotes: 0
Views: 77
Reputation: 695
Using lubridate, you could do
time <- as_datetime("Tue May 01 23:02:50 GMT+03:00 2018",
format = "%a %b %d %H:%M:%S GMT+03:00 %Y",
tz = "Etc/GMT-3")
time
[1] "2018-05-01 23:02:50 +03"
Then if you want to see it in your timezone you could do something like
with_tz(time, tzone = "America/New_York")
[1] "2018-05-01 16:02:50 EDT"
where the tzone argument would be your timezone.
If there are different timezones in your data other than GMT+3:00, this won't work though. If this is the case, you can check out Reading timestamp data in R from multiple time zones.
Upvotes: 2