Iván Cortés Romero Iván Cortés Romero - 5 months ago 26x
Ruby Question

yyyy-mm-ddThh:mm:ss.000Z date format in Ruby

I am consuming an API which returns a date like this

. This format is new for me, so, What is the name of this date format? and, how can I treat it in Ruby?


That's an ISO 8601 date and DateTime.parse has no trouble parsing it:

require "date"

str = "2016-05-05T20:59:31.000Z"
p DateTime.parse(str)
# => #<DateTime: 2016-05-05T20:59:31+00:00 ((2457514j,75571s,0n),+0s,2299161j)>