I’ve got the following time string that I need to convert to a number of seconds since midnight (start of day). I’ve been looking in the Ruby Api but haven’t been able to come up with a solution. Any ideas would be appreciated.
time_string = '4:12:38 PM ET'
To convert your string to a time use
This will return a Time object. Then you can just subtract the time at midnight from your given time like so:
Of course, for Time.local, you should use today’s date, not the hardcoded values as above.