I need to convert a date string to the Unix timestamp format. The string I get from an API looks like:
2015-05-27T07:39:59Z
with .tr()
i get:
2015-05-27 07:39:59
which is a pretty regular date format. Nonetheless, Ruby isn't able to convert it to Unix TS format. I tried .to_time.to_i
but I keep getting NoMethodError
Errors.
In PHP the function strtotime()
just works perfectly for this.
Is there some similar method for Ruby?