LoginSignup
0
0

More than 1 year has passed since last update.

#Ruby or #Rails で 2月末の日付を得る ( 28日 or 29 日 ) (閏年対応 )

Last updated at Posted at 2019-07-06

Ruby の場合は gem install activesupport しておく

require 'active_support/all'  # Rails の場合は不要

Date.new(2019,2).end_of_month # => Thu, 28 Feb 2019
Date.new(2019, 2).end_of_month.day # => 28

Date.new(2020,2).end_of_month # => Sat, 29 Feb 2020
Date.new(2020, 2).end_of_month.day # => 29

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

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