1 /** 2 * @fileOverview 組み込みクラスであるDate型を拡張するJSファイルです。 3 * 4 * @author Naoki Yamada 5 * @version 1.0.0 6 */ 7 8 /** 9 * 日付を文字列型にして返す<br /> 10 * <br /> 11 * ここに拡張機能の説明を記述します。 12 * 13 * @param {String} date 対象日付 14 * @return {String} YYYYMMDD形式の文字列 15 * 16 * @example 今日の日付を文字列型にして返す。 17 * var date = new Date(); 18 * d.encodeString(); 19 */ 20 Date.prototype.encodeString = function() { 21 var y = this.getFullYear(); 22 var m = ('0' + (this.getMonth() + 1)).substr(-2); 23 var d = ('0' + this.getDate()).substr(-2); 24 return ('' + y + m + d); 25 }