-1

How can I convert from a formatted time string (e.g. 3/17/98) to a Unix time stamp (i.e. num. seconds from Jan 1, 1970 00:00:00)?

I can find many methods of converting into a date string in the Ruby "date" library, but none to go back the other way. While this won't be a problem in later builds, my proof of concept application is using a SQLite database which does not support the "DATE" type format.

sawa
  • 165,429
  • 45
  • 277
  • 381
Leo G.
  • 28
  • 5

1 Answers1

0

To convert the string into an array of integers, look into split('/'), to turn that into a unix time stamp look here (you probably want to_i but be warned that it incorporates your local time zone).

Asone Tuhid
  • 539
  • 4
  • 13