0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Ruby】Timeクラス 曜日の出力方法

Posted at

はじめに

自己学習の復習として投稿します。

何も使わず出力した時

now = Time.new
puts now.wday

出力結果は、0~7 の数字で出力されます。

曜日で出力したい場合は?

now = Time.new
week = ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日","土曜日"]
puts week[now.wday]

このように、曜日を配列で記述する必要があります。
基本的に出力される数字は日曜日から始まっている為、配列も日曜日から始めてます。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?