Skip to content

Instantly share code, notes, and snippets.

@wikiti
Created October 2, 2018 13:28
Show Gist options
  • Save wikiti/deb9617b87c520c98a4a1b7bfd28f94e to your computer and use it in GitHub Desktop.
Save wikiti/deb9617b87c520c98a4a1b7bfd28f94e to your computer and use it in GitHub Desktop.
Parse any datetime string on any known timezone
# Fetch a Rails timezone, and use it to parse a string
ActiveSupport::TimeZone[time_zone].parse(str)
# For example:
ActiveSupport::TimeZone['Madrid'].parse('2018-08-30 14:36')
# Thu, 30 Aug 2018 14:36:00 CEST +02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment