Ruby 时间 now()函数 now() 是Ruby中一个内置的方法,用于返回当前时间。 语法 :time.now() 参数 :该函数不接受任何参数 返回值 : 它返回当前时间 例子 1 : # Ruby code for now() method # Include Time require 'time' # Declaring time a = Time.now() # Prints current time puts aRubyCopy 输出: 2019-08-27 08:26:42 +0000RubyCopy 例2 : # Ruby code for now() method # Include Time require 'time' # Declaring time a = Time.now() # Prints current time puts aRubyCopy 输出: 2019-08-27 08:26:42 +0000RubyCopy