Skip to content

Instantly share code, notes, and snippets.

@basti
Last active October 22, 2017 16:42
Show Gist options
  • Save basti/6634820 to your computer and use it in GitHub Desktop.
Save basti/6634820 to your computer and use it in GitHub Desktop.
Snippet to convert PayPal date format to DateTime (taken from: http://rhnh.net/2008/03/17/paypal-ipn-fails-date-standards)
# taken from: http://rhnh.net/2008/03/17/paypal-ipn-fails-date-standards
# parses PayPal non-standard format
DateTime.strptime("18:30:30 Jan 1, 2000 PST", "%H:%M:%S %b %e, %Y %Z").new_offset(0)
# in Rails you can use to_time_in_current_zone to convert it to TimeWithZone
DateTime.strptime("18:30:30 Jan 1, 2000 PST", "%H:%M:%S %b %e, %Y %Z").to_time_in_current_zone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment