実行結果
Dateオブジェクトを文字列に変換
Dateオブジェクトを指定したフォーマット文字列で取得
Dateオブジェクトから月末の日付を文字列として取得
Dateオブジェクトから月末の日付を取得し、指定したフォーマット文字列で取得
Dateオブジェクトの日付を現在日時に変換
Dateオブジェクトの日付を現在日時に変換し、指定したフォーマット文字列で取得
現在日時から1ヵ月後の日付を求める
現在日時から2ヵ月前の日付を求める
現在日時から36ヵ月後(3年後)の日付を求める
設置サンプルのソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>jQuery.exDate.js | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/exdate.js"></script>
<script type="text/javascript">
$(function(){
var date=$.exDate("23:58 2009/03/30","hh:mi yyyy/mm/dd");
$("#res_tochar").text(date.toChar());
$("#res_tochar_format").text(date.toChar("yyyy年mm月dd日 hh時mi分"));
$("#res_lastday").text(date.lastDay().toChar());
$("#res_lastday_format").text(date.lastDay().toChar("yyyy年mm月dd日 hh時mi分"));
$("#res_todate").text(date.toDate().toChar());
$("#res_todate_format").text(date.toDate().toChar("yyyy年mm月dd日 hh時mi分ss秒"));
$("#res_addmonths").text(date.addMonths(1).toChar("yyyy年mm月dd日 hh時mi分"));
$("#res_addmonths_past").text(date.addMonths(-2).toChar("yyyy年mm月dd日 hh時mi分"));
$("#res_addmonths_feature").text(date.addMonths(36).toChar("yyyy年mm月dd日 hh時mi分"));
});
</script>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1><a href='http://d.hatena.ne.jp/cyokodog/20090316/jQueryExDate'>jQuery.exDate.js</a> | 設置サンプル</h1>
<!-- CODE -->
<h2>Dateオブジェクトを文字列に変換</h2>
<p id="res_tochar"></p>
<h2>Dateオブジェクトを指定したフォーマット文字列で取得</h2>
<p id="res_tochar_format"></p>
<h2>Dateオブジェクトから月末の日付を文字列として取得</h2>
<p id="res_lastday"></p>
<h2>Dateオブジェクトから月末の日付を取得し、指定したフォーマット文字列で取得</h2>
<p id="res_lastday_format"></p>
<h2>Dateオブジェクトの日付を現在日時に変換</h2>
<p id="res_todate"></p>
<h2>Dateオブジェクトの日付を現在日時に変換し、指定したフォーマット文字列で取得</h2>
<p id="res_todate_format"></p>
<h2>現在日時から1ヵ月後の日付を求める</h2>
<p id="res_addmonths"></p>
<h2>現在日時から2ヵ月前の日付を求める</h2>
<p id="res_addmonths_past"></p>
<h2>現在日時から36ヵ月後(3年後)の日付を求める</h2>
<p id="res_addmonths_feature"></p>
<!-- / CODE -->
</div>
</body>
</html>