📜  在 ruby 代码示例中获取当前年份

📅  最后修改于: 2022-03-11 15:04:50.060000             🧑  作者: Mango

代码示例1
# Using the Time class
current_year = Time.new.year
current_year = Time.now.year

# Using the Date class
current_year = Date.today.year

# Using the DateTime class
current_year = DateTime.now.year