首页 > 学院 > 开发设计 > 正文

JS Date日期时间对象格式化

2019-11-11 05:01:50
字体:
来源:转载
供稿:网友

JS Date日期时间对象格式化

function dateToStr( datetime ) {	var year = datetime.getFullYear(),	month = datetime.getMonth()+1,	date = datetime.getDate(),	hour = datetime.getHours(),	minutes = datetime.getMinutes(),	second = datetime.getSeconds();	if ( month < 10 ) {		month = "0" + month;	}	if ( date < 10 ) {		date = "0" + date;	}        if ( hour < 10 ) {		hour = "0" + hour;	}	if ( minutes < 10 ) {		minutes = "0" + minutes;	}	if ( second < 10 ) {		second = "0" + second;	}	return (year+"-"+month+"-"+date+" "+hour+":"+minutes+":"+second);}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表