简体   繁体   中英

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.

try following:

start_date.iso8601

output

=> "2015-05-06T15:53:51+05:00"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM