js 格式化日期
//格式化日期 function formatDate(d){ var date1=new Date(d); var CurrentDate = ""; //初始化时间 var Year= date1.getFullYear();//ie火狐下都可以 var Month= date1.getMonth()+1; var Day = date1.getDate(); var Hours = date1.getHours(); var Minutes = date1.getMinutes(); var Seconds = date1.getSeconds(); CurrentDate += Year + "年"; Month >= 10 ? (CurrentDate += Month + "月"):(CurrentDate += "0" + Month + "月"); Day >= 10 ? (CurrentDate += Day +"日 "):(CurrentDate += "0" + Day+"日 "); Hours>=10 ? (CurrentDate += Hours +":"):(CurrentDate += "0"+Hours +":"); Minutes>=10 ? (CurrentDate += Minutes +":"):(CurrentDate += "0"+Minutes +":"); Seconds>=10 ? (CurrentDate += Seconds):(CurrentDate += "0"+Seconds); return CurrentDate; }
作者:freddyhuang
出处:https://www.cnblogs.com/freddyhuang
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。