Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby string to date

str = "Tue, 10 Aug 2010 01:20:19 +0400"
puts Date.parse str
2010-08-10
puts Date.parse(Time.parse(str).utc.to_s)
2010-08-09

Or simply
Time.zone.parse(str) # using Time with zone is a good rule of thumb
Comment

rails string to date

"1-1-2012".to_date   # => Sun, 01 Jan 2012
"01/01/2012".to_date # => Sun, 01 Jan 2012
"2012-12-13".to_date # => Thu, 13 Dec 2012
"12/13/2012".to_date # => ArgumentError: invalid date
Comment

convert string to date ruby

date = Date.strptime(start_date, ‘%d/%m/%y’)
Comment

PREVIOUS NEXT
Code Example
Ruby :: activerecord list tables 
Ruby :: find records created in a particular month rails 
Ruby :: ruby remove unsafe file characters 
Ruby :: rspec expect to receive multiple times 
Ruby :: dotenv-rails comments 
Ruby :: convert string to hash ruby 
Ruby :: ruby constructor 
Ruby :: rails routes grep 
Ruby :: ruby replace first character in string 
Ruby :: ruby intersection of two arrays 
Ruby :: contains ruby array 
Ruby :: add key and value to hash ruby 
Ruby :: ruby make chain method 
Ruby :: how to get ip address of client using rails 
Ruby :: rails migration add default value 
Ruby :: print in ruby 
Ruby :: singleton class in ruby 
Ruby :: rails send email from console 
Ruby :: ruby create engine using rspec and dummy 
Ruby :: render partial rails 
Ruby :: ruby append to array 
Ruby :: ruby os command injection 
Ruby :: .delete ruby 
Ruby :: ruby is method defined 
Ruby :: ruby for programmers 
Ruby :: ruby clone vs dup 
Ruby :: ruby assign rest of array 
Ruby :: ruby find multiple indices in an array for a value the same value 
Ruby :: csv file current row number ruby 
Ruby :: OTP SMS Mobile Verification in Ruby 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =