红宝石 |时间 asctime()函数
asctime()是 Ruby 中的一个内置方法,它返回时间的规范字符串表示。
Syntax: time.asctime()
Parameters: The function accepts no parameter
Return Value: It returns a canonical string representation of time.
示例 1 :
# Ruby code for asctime() method
# Include Time
require 'time'
# Declaring time
a = Time.new(1993, 02, 24, 12, 0, 0, "+09:00")
# Prints time as string
puts a.asctime()
输出:
Wed Feb 24 12:00:00 1993
示例 2 :
# Ruby code for asctime() method
# Include Time
require 'time'
# Declaring time
a = Time.now.asctime()
# Prints time as string
puts a
输出:
Tue Aug 27 08:22:03 2019