By using XML API, I got date-time as "2008-02-05T12:50:00Z". Now I wanna convert this text format into different format like "2008-02-05 12:50:00". But I am getting proper way.
I have tried this one :: @a = "2008-02-05T12:50:00Z"
Steps
1. @a.to_date
=> Tue, 05 Feb 2008
2. @a.to_date.strftime('%Y')
=> "2008"
3. @a.to_date.strftime('%Y-%m-%d %H:%M:%S')
=> "2008-02-05 00:00:00
Suggest some thing ?
The
to_datemethod converts your string to a date but dates don’t have hours, minutes, or seconds. You want to useDateTime: