如何转换“2016年3月28日23:59:59 GMT -0600(中央日间时间)”至“2016-03-28 23:59:59”(YYYY-MM-DD HH:MM:SS )在javascript中?
答案 0 :(得分:0)
试试这个,
var d=your date;
var actualDate=d.toLocaleString();
希望这有帮助。
答案 1 :(得分:0)
您可以使用moment.js进行日期时间转换
答案 2 :(得分:0)
检查
function addZero(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function myFunction() {
var d = new Date();
var x = document.getElementById("demo");
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
var s = addZero(d.getSeconds());
x.innerHTML = h + ":" + m + ":" + s;
}
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear(),
h = addZero(d.getHours()),
m = addZero(d.getMinutes()),
s = addZero(d.getSeconds());
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day].join('-')+" "+[h,m,s].join(':');
}
document.getElementById('res').innerHTML = formatDate('Mon March 28 2016 23:59:59 GMT -0600 (CENTRAL DAYLIGHT TIME)') ;
答案 3 :(得分:0)
试试这个,
在你看来,
columns.Bound("YOUR MODEL").Format("
{0:n6}").ClientTemplate("#=SAMPLEDATEDISPLAY#").Title("Sample Date");
在你的模型中,
public Nullable<System.DateTime> SAMPLEDATE{ get; set; }
public string SAMPLEDATEDISPLAY{ get { return SAMPLEDATE.HasValue ? SAMPLEDATE.Value.ToString() : string.Empty; } }
请反馈:)