-3

I want to convert the following format into a standard date format in R:

2013-05-22 02:00pm

to

2013-05-22 14:00

I've tried using strptime, but it outputs 2013-05-22 02:00 MST, which would mean 2AM. How do I fix this?

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
Moon_Watcher
  • 416
  • 1
  • 6
  • 19

1 Answers1

2

?strptime says you must use "%I" (not "%H") with "%p".

> strptime('2013-05-22 02:00pm', tz="UTC", format="%Y-%m-%d %I:%M%p")
[1] "2013-05-22 14:00:00 UTC"
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418