公共方法含时间格式化
var common = {};
common.ipadress = "http://10.200.200.131:1111/"; //JS中定义的属性
common.method =
{
live: function () {
$(".option_box ul").die().live("click", function () {
var v = $(this).html();
alert(v);
});
},
bind: function () {
$(".option_box ul").die().bind("click", function () {
var v = $(this).html();
alert(v);
});
},
existapp: function (existobj) {
existobj.tap(function () {
navigator.notification.confirm('确定要退出系统?', function (index) {
if (index == 2) {
navigator.app.exitApp();
}
}, '温馨提示', '取消,确定');
});
},
/******** changedateformat格式化时间数据*************************************/
/*time :时间数据 */
/*return :格式化后的时间 */
/****************************************************************************/
ChangeDateFormat: function (time) {//时间格式转换
if (time != null) {
var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
var year = date.getFullYear();
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return year + "-" + month + "-" + currentDate + " " + hour + ":" + minute + ":" + second;
}
},
ChangeDate: function (time) {
if (time != null) {
var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
var year = date.getFullYear();
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return month + "-" + currentDate;
}
},
ChangeTime: function (time) {
if (time != null) {
var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10));
var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return hour + ":" + minute;
}
},
getpartDate: function (str, start, length) {
var subStr = "";
if (str.length > length) {
subStr = str.substring(start, length);
} else {
subStr = str;
}
return subStr;
}
}

浙公网安备 33010602011771号