tags

Rubyで現在時刻を表示する

Rubyで現在時刻を表示する

require 'date'
puts Date.today             # 2017-04-01
puts Date.today.to_time     # 2017-04-01 00:00:00 +0900
puts Time.now               # 2017-04-01 10:13:53 +0900

#  2017/04/01 10:13:53
time = DateTime.now
printf("%04d/%02d/%02d %02d:%02d:%02d\n",time.year, time.month, time.day, time.hour, time.min ,time.sec)

No.1083
01/31 10:59

edit