js取整数四舍五入
1.丢弃小数部分,保留整数部分
parseInt(5/2)
2.向上取整,有小数就整数部分加1
Math.ceil(5/2)
3,四舍五入.
Math.round(5/2)
4,向下取整
Math.floor(5/2)
var DateToUnix = function(year, month, day, hour, minute, second){
var oDate = new Date(Date.UTC(parseInt(year), parseInt(month), parseInt(day), parseInt(hour), parseInt(minute),parseInt(second)));
return (oDate.getTime()/1000);
};
//运用在上边代码转化有问题
var dateint = new Date('2014/05/08 11:12:13').getTime()/1000;
$.date(dateint);
var UnixToDate=function(unixTime, isFull, timeZone){
if (typeof(timeZone) === 'number'){
unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
}
var time = new Date(unixTime*1000);
var ymdhis = "";
ymdhis += time.getUTCFullYear() + "-";
ymdhis += time.getUTCMonth() + "-";
ymdhis += time.getUTCDate();
if ( isFull === true ){
ymdhis += " " + time.getUTCHours() + ":";
ymdhis += time.getUTCMinutes() + ":";
ymdhis += time.getUTCSeconds();
}
return ymdhis;
};