0
1

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 3 years have passed since last update.

[Ruby]Dateクラスで日付を扱う

Last updated at Posted at 2020-02-07

RubyのDateクラスについて

  • RubyのDateクラスを使用することで『日付』を扱うことができます。

 # Dateクラスを読み込む
 require "date"

 # Date.newの引数に年月日を渡して、変数dayに格納
 day = Date.new(2020,2,22)

 # dayの出力結果は「2020-02-22」となる
 puts day

 # 「sunday?」メソッドは日付が日曜日かどうか真偽値を返す
 puts day.sunday?

Dateクラスの便利な使い方やメソッドについて、また随時更新していきたいと思います!
ご覧いただきありがとうございました!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?