JSP:在 datetimepicker 的 <form:input> 字段中将日期格式化为“yyyy-MM-dd h:mm a”

问题描述

<div class="col-xs-12 col-sm-6 col-md-3">
    <label for="appointment_date" class="required" style="margin-left:30px">Appointment Date: <span class="blue">*</span></label>
    <input id="appointment_date" name="appointment_date" type="text" class="form-control" data-datetimepicker="" required style="margin-left:30px;width: 190px;">
</div>

修改后的.js 页面如下

$('#appointment_date').datetimepicker({
                controlType: 'select',oneLine: true,timeFormat: 'hh:mm TT',showSecond: false,showMillisec: false,showMicrosec: false,showTimezone: false
            });

有人可以帮助我以“yyyy-MM-dd h:mm a”的格式获取日期吗?

我尝试了以下方法但没有奏效:

<div class="col-xs-12 col-sm-6 col-md-3">
     <label for="appointment_date" class="required" style="margin-left:30px">Appointment Date: <span class="blue">*</span></label>
     <fmt:formatDate pattern="yyyy-MM-dd h:mm a"  type="date"  value="${appointment_date}" var="FormattedDate"/>
     <input id="appointment_date" name="appointment_date" type="text" class="form-control" data-datetimepicker="" required value="${FormattedDate}" style="width: 190px;">
</div>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)