Answers for "rails get year date now"

1

get current year in ruby

# 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
Posted by: Guest on March-02-2021
0

get date millis rails

require 'date'
DateTime.now.strftime('%s') # "1384526946" (seconds)
DateTime.now.strftime('%Q') # "1384526946523" (milliseconds)
Posted by: Guest on June-04-2021

Browse Popular Code Answers by Language