var today = new Date();
//$('#timeStampID').val(today.getFullYear() + '-' +
('0' + (today.getMonth() + 1)).slice(-2) + '-' + ('0' +
today.getDate()).slice(-2));
$('#timeStampID').val(String(('0' +
today.getDate()).slice(-2)) + ' ' +
String(('0' + (today.getMonth() + 1)).slice(-2)) + ' ' +
String(today.getFullYear()));
这里我输入的输出文件为:23 04 2018 但我想显示Apr代替04,即月份名称
答案 0 :(得分:3)
不幸的是,没有一种方法可以将其内置到Date对象中。但你可以这样做:
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var monthName = months[today.getMonth()];