我正在从 API 中检索日期,其格式为:
Thu, 13 Dec 2012 12:59:05 +0200
请注意,上述格式打印为字符串,我想将其格式化为:
Thu, 12:59
如果不多次使用 jQuery replace(),最简单的方法是什么?
尝试这个 -
var st = "Monday, 9 Jan 2012 12:59:05";
var dt = new Date(st);
var m_names = new Array("Sun", "Mon", "Tue","Wed", "Thu","Fri", "Sat");
var dayInNum =dt.getDay();
var desireDate = m_names[dayInNum] + ","+ dt.getHours() +":"+ dt.getMinutes();
alert(desireDate);