Time.parse undefined method error in Ruby

You may get this error when trying to use Time.parse in a Ruby script:

undefined method `parse' for Time:Class (NoMethodError)

If so, try adding this line to the top of your script:

require 'time'

It seems there are some Time methods which are not automatically imported into Ruby scripts unlike the standard library Time methods.

The first comment on this archlinux forum topic has a little more discussion about this.

See this Time.parse snippet for some examples of how to use this method.

Tags: