LoginSignup
1
0

More than 5 years have passed since last update.

Time

Posted at
1.day #=> 86400
2.days #=> 172800

Time.now.to_i #=> 1334222062

Time.at(1334222062) #=> 2012-04-12 18:14:22 +0900
Time.at(1334222062) + 1.day #=> 2012-04-13 18:14:22 +0900

Time.at(1334222062).to_s(:db) #=> "2012-04-12 18:14:22"

Time::DATE_FORMATS[:date_ordinal] = lambda { |time| time.strftime("%b #{time.day.ordinalize} %Y") }
Time.at(1334222062).to_s(:date_ordinal) #=> "Apr 12th 2012"

Time.local(2012, 4, 12)   #=> 2012-04-12 00:00:00 +0900

Time.now.beginning_of_day #=> 2012-04-12 00:00:00 +0900
Time.now.end_of_day       #=> 2012-04-12 23:59:59 +0900
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0