LoginSignup
0
0

More than 1 year has passed since last update.

datepicker, timepickerを使うほどじゃない 1~31の配列, 00:00~23:00の配列作成

Posted at

セレクトボックスで頑張る人向け

突貫メソッド2つ

1 ~ 31 の配列作成 [1, 2, 3,...31]

31days
    const arrayDays = () => {
        const days = [];
        for (let i = 1; i <= 31; i += 1) {
            days.push(i);
        }
        return days;
    };

00:00 ~ 23:00 の配列作成 [00:00, 01:00, 02:00,...23:00]

24times
    const arrayTimes = () => {
        const times = [];
        for (let i = 0; i <= 23; i += 1) {
            times.push(`${i.toString().padStart(2, '0')}:00`);
        }
        return times;
    };
0
0
2

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