Prototype-date-tojson

提供:Dev Guides
移動先:案内検索

プロトタイプ-Date.toJSON()メソッド

このメソッドは、日付をJSON文字列に変換します(JSONで使用されるISO形式に従います)。

構文

Date.toJSON();

戻り値

指定された日付の文字列を返します。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function showResult() {
            var str = new Date(1969, 11, 31, 19).toJSON();
            alert ("Returns JSON String: " + str );
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br/>

      <br/>
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

出力