【发布时间】:2016-07-19 12:51:52
【问题描述】:
datepicker的代码如下:
$("#startDate").datepicker({
autoclose:true,
startView:"months",
minViewMode:"months",
orientation: "bottom",
format: "dd-MM-yyyy"
}).on('changeDate', function(selected){
startDate = new Date(selected.date.valueOf());
startDate.setDate(startDate.getDate(new Date(selected.date.valueOf())));
$('.to').datepicker('setStartDate', startDate);
});
$("#endDate").datepicker({
autoclose:true,
startView:"months",
minViewMode:"months",
orientation: "bottom",
format: "dd-MM-yyyy"
}).on('changeDate', function(selected){
FromEndDate = new Date(selected.date.valueOf());
FromEndDate.setDate(FromEndDate.getDate(new Date(selected.date.valueOf())));
$('.from').datepicker('setEndDate', FromEndDate);
});
我在前端得到的格式是:
2016 年 1 月 1 日
现在我需要的格式为:
2016 年 1 月
在日期选择器(前端)框中,而 01-01-2016 在后端。我怎样才能做到这一点?请大家帮帮我。
【问题讨论】:
-
先告诉我后端使用哪种语言
-
我到处都在使用 javascript。事实上,我正在获取日期值来过滤 D3js 中的数据。 @taposghosh
-
使用此库将您的日期转换为任何格式momentjs.com
标签: twitter-bootstrap datepicker bootstrap-datepicker