js /Date(1550273700000)/ 格式转换


self.FormatJsonDate = function (jsonStr) {
var tmp = "";
if (jsonStr == null || jsonStr == '')
return '';
if (jsonStr != null || jsonStr != undefined)
tmp = jsonStr.toString();
var seconds = tmp.replace(/\/Date\(/, "").replace(/\)\//, "");

var now = new Date(parseInt(seconds));
return now.asString("yyyy-mm-dd hh:ii:ss");
};

//从JSON格式的日期格式化为yyyy-mm-dd
self.FormatYMD = function (jsonStr) {
var tmp = self.FormatJsonDate(jsonStr);
tmp = tmp.substr(0, 10);
return tmp;
};

//从JSON格式的日期格式化为yyyy-mm-dd hh:mm:ss
self.FromatYMDHI = function (jsonStr) {
var tmp = self.FormatJsonDate(jsonStr);
tmp = tmp.substr(0, 19);

return tmp;
};

//从JSON格式的日期格式化为yyyy-mm-dd hh:mi
self.FromatYMDHM = function (jsonStr) {
var tmp = self.FormatJsonDate(jsonStr);
tmp = tmp.substr(0, 16);

return tmp;
};


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM