How would I go about converting 2012-12-13T14:43:35.371Z to epoch time?
One approach I was considering was to strip the T and Z and then try to use the DateTime library to find a way to convert to epoch. Before I go down that path, I was curious if there is a gem I could use to do this quickly. On a related note, I will be doing time calculations after I convert to epoch.
For example:
require 'date'
# as an integer:
DateTime.parse('2012-12-13T14:43:35.371Z').to_time.to_i
# or as a string:
DateTime.parse('2012-12-13T14:43:35.371Z').strftime('%s')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With