红宝石 |现在时间()函数
now()是 Ruby 中的一个内置方法,用于返回当前时间。
Syntax: time.now()
Parameters: The function accepts no parameter
Return Value: It returns the current time
示例 1 :
# Ruby code for now() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints current time
puts a
输出:
2019-08-27 08:26:42 +0000
示例 2 :
# Ruby code for now() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints current time
puts a
输出:
2019-08-27 08:26:42 +0000