ruby get current datetime
require 'date'
current_datetime = DateTime.now
ruby get current datetime
require 'date'
current_datetime = DateTime.now
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us