時刻は世界標準時の1970/1/1からの経過秒数で保持されている
Time.new Time.now Time.at Time.mktime Time.local Time.gm
Timeオブジェクトの属性を取得
year mon / month day / mday hour min usec / tv_usec wday : 曜日を0から6までの数字で返す(日=0) yday : 1/1からの日数 zone isdst / dst? : 夏時間かどうか gmt? / utc? : タイムゾーンがutcかどうか gmt_offset / gmtoff : utc時刻との差を秒単位で返す
タイムゾーンの変更
localtime : ローカルタイムに変更 gmtime / utc : utcに変更 getlocal : ローカルタイムに変更した新しいオブジェクトを返す getgm / getutc : utcに変更した新しいオブジェクトを返す
Timeオブジェクトの変更
to_i / tv_sec to_f to_a : 日付を秒、分、時、日、月、年、曜日、夏時間、タイムゾーンの順で配列で返す to_s strftime : 指定したフォーマットで返す
例
t = Time.mktime(2011,1,2,3,4,5,6) => Sun Jan 02 03:04:05 +0900 2011 t.strftime("%Y-%m-%d %H:%M:%S") => "2011-01-02 03:04:05"