Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

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
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails remove reference 
Ruby :: ruby hash map key value 
Ruby :: ruby constructor 
Ruby :: index name is too long rails 
Ruby :: how to add uniqueness in rails migration 
Ruby :: ruby non greedy regex 
Ruby :: rails validators 
Ruby :: ruby loop from the last array item 
Ruby :: Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1 
Ruby :: add key and value to hash ruby 
Ruby :: rails remove model 
Ruby :: rails reset database 
Ruby :: ruby hash merge 
Ruby :: rails hidden field default value 
Ruby :: default value rails migration 
Ruby :: rails check routes in console 
Ruby :: rails run rspec 
Ruby :: ruby rails controller 
Ruby :: heroku run rails c 
Ruby :: font awesome icon rails submit button 
Ruby :: rails image disappears after showing 
Ruby :: rbenv not changing version 
Ruby :: rails subdomain 
Ruby :: ruby map 
Ruby :: ruby simbolize element from hash 
Ruby :: sidekiq configuration file 
Ruby :: add several columns rails 
Ruby :: pick element from space separated list that is part of params hash 
Ruby :: apple calendar gem in rails 
Ruby :: send email rails c one line 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =