Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery tmpl格式化日期?_Jquery_Json_Templates - Fatal编程技术网

jquery tmpl格式化日期?

jquery tmpl格式化日期?,jquery,json,templates,Jquery,Json,Templates,我使用jQueryTMPL在表中显示一组结果。其中一个是我在模板中使用以下内容输出的日期: <td class="textAlignRight">${EffectiveDate}</td> ${EffectiveDate} 但它的格式是“/Date(1245398693390)/”。我如何更改它,使它的格式像m/dd/yyyy h:mm tt 只需使用函数设置日期格式: 模板: <td class="textAlignRight">${GetDate(Ef

我使用jQueryTMPL在表中显示一组结果。其中一个是我在模板中使用以下内容输出的日期:

<td class="textAlignRight">${EffectiveDate}</td>
${EffectiveDate}

但它的格式是“/Date(1245398693390)/”。我如何更改它,使它的格式像m/dd/yyyy h:mm tt

只需使用函数设置日期格式:

模板:

<td class="textAlignRight">${GetDate(EffectiveDate)}</td>
{{=format(新日期(parseInt(EffectiveDate.substr(6)),'d')}

我建议您使用以下内容:

<script type='text/javascript'>
    Date.prototype.CustomFormat = function () {
        return this.getMonth() + 1 + "/" + this.getDate() + "/" + this.getFullYear();
    };
</script>

Date.prototype.CustomFormat=函数(){
返回this.getMonth()+1+“/”+this.getDate()+“/”+this.getFullYear();
};

${EffectiveDate.CustomFormat()}

需要将GetDate()函数粘贴到哪里?在<代码>准备就绪<代码>?
<td class="textAlignRight">{{= format(new Date(parseInt(EffectiveDate.substr(6))), 'd') }}</td>
<script type='text/javascript'>
    Date.prototype.CustomFormat = function () {
        return this.getMonth() + 1 + "/" + this.getDate() + "/" + this.getFullYear();
    };
</script>
<td class="textAlignRight">${EffectiveDate.CustomFormat()}</td>