LoginSignup
1
3

More than 5 years have passed since last update.

2000年から本日までの年を全て表示

Last updated at Posted at 2018-11-29
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>2000年から本日までの年を全て表示</title>
</head>
<body>
    <script>
        // 現在日時を取得
        var date = new Date(); //秒まで取得できる
        // 現在日時から「年」のみを取得
        // dateオブジェクトから西暦のみを取るのがgetFullYeaメソッドの役割
        var year = date.getFullYear(); //2018がyaerに入る

        for (var i = 2000; i<= year; i++) {
        document.write('<p>' + i + '</p>')
        }
    </script>
</body>
</html>

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

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