首页 > 解决方案 > JSP:在 a 中将日期格式设置为“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>

modified.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>

标签: javajqueryjstl

解决方案


推荐阅读