score:0

You can use Activesupport String#in_time_zone

in_time_zone(zone = ::Time.zone)Link Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default is set, otherwise converts String to a Time via String#to_time

score:2

In Rails you can convert a properly formatted string to milliseconds with:

"2014-06-16 16:00:00".to_datetime.strftime('%Q')

score:14

You need to covert sstring to dateTime as the first, Use this code:

DateTime.parse("2011-05-19 10:30:14").strftime('%Q')

Or this code:

"2014-06-16 16:00:00".to_datetime.strftime('%Q')

So you can convert array of strings of dates as the following:

dates.map!{|d| d.to_datetime.strftime('%Q')}

Helper links: link-1, link-2


Related Query

More Query from same tag