$(function(){ //当前时间格式化yyyy-MM-dd HH:mm:ss console.log(timeFormat(new Date().getTime())); }); //在Jquery里格式化Date日期时间数据 function timeFormat(time){ var datetime = new Date(); datetime.setTime(time); var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(); var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours(); var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(); var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(); return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second; }
在Jquery里格式化Date日期时间数据
最新推荐文章于 2023-07-10 16:16:00 发布