Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Rails Datetime to YYYY-MM-DDThh:mm:ssZ

I have ann app that has a start_date and an end_date that is currently in the format Thu, 23 Apr 2015 17:00:00 UTC +00:00 and the field type is datetime.

I am needing to convert it into this YYYY-MM-DDThh:mm:ssZ for the Eventbrite API but I am having little luck.

I have tried iso = Time.iso8601(start_date) but I get the following error TypeError: no implicit conversion of ActiveSupport::TimeWithZone into String

Anyone able to point me in the right direction it would be very much appreciated.

like image 378
DMH Avatar asked Mar 17 '23 04:03

DMH


1 Answers

try following:

start_date.iso8601

output

=> "2015-05-06T15:53:51+05:00"
like image 108
Abdul Baig Avatar answered Mar 30 '23 15:03

Abdul Baig