您好我有这个输入日期,只有很小的变化: - 明天可用的日子 - 明天默认的一天 - 和日期格式dd / mm / yyyy
$(document).ready(function() {
var now = new Date();
var day = ("0" + (now.getDate() + 1)).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear() + "-" + (month) + "-" + (day);
$('.dateD').val(today).attr("min", today);
});
但我需要月份作为名称而不是数字,1月,2月等...
因此日期应为:2017年2月4日
谢谢你!答案 0 :(得分:0)
您可以尝试使用datepicker进行格式化:
答案 1 :(得分:0)
因此日期应为:2017年2月4日
无法设置(更改)<input type="date" />
的自定义格式。它需要一个等于的全日期格式: yyyy-mm-dd
要以 dd / Month / yy 格式呈现当前日期,请使用以下Date.prototype.toLocaleString()的简短解决方案:
var now = new Date(),
day = ("0" + (now.getDate())).slice(-2),
// the first argument 'en-us' is a locale(you can adjust it)
today = day + '/'
+ now.toLocaleString('en-us', { month: "long" })
+ "/" + now.getFullYear();
$('.dateD').val(today).attr("min", today);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="dateD" type="text" readonly='true'/>
答案 2 :(得分:0)
您可以使用Internationalization API。此代码段仅适用于现代浏览器。见browser compability
public DatabaseManager(Context context) {
super(context, DATABASE_NAME, null, 1);
}