★ wanayoo — archive 1999 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSONNouvelle recherche | Portail wanayoo

Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at https://viewsourceconf.org/.

Date.prototype.toJSON()

by 2 contributors:

概要

Date オブジェクトを JSON シリアライズして返します。

構文

date.toJSON()

説明

Date インスタンスは時間中の特定の地点(特定時刻)を参照するものです。

toJSON() メソッドは Date オブジェクトの値を表す JSON 形式の文字列(ISO 8601 フォーマットの日付文字列)を返します。このメソッドは、通常、Date オブジェクトを簡単に JSON シリアライズすることを意図するものです。

例

var myDate = new Date();
var jsonDate = myDate.toJSON();
var backToDate = new Date(jsonDate);
 
console.log(
  " 元の Date オブジェクト : " + myDate,
  "シリアライズ後の Date オブジェクト : " + jsonDate,
  "シリアライズ後、再度 Date オブジェクトに戻したもの : " + backToDate
);

関連情報

ドキュメントのタグと貢献者

タグ: 
Contributors to this page: teoli, ethertank
最終更新者: teoli,
サイドバーを隠す