涉及到显示本月或本周相关信息,又不想让php去判断,只好直接用js去计算,麻烦了好一阵,还是老老实实的看了下js的日期函数.现总结一下: //计算本周起始日期,并以 Y-m-d 形式返回. function getWeekTime() { var now = new Date(); var Year = now.getFullYear(); var Month = now.getMonth() + 1; var Day = now.
/** *获取当前时间 *format=1精确到天 *format=2精确到分 */ function getCurrentDate(format) { var now = new Date(); var year = now.getFullYear(); //得到年份 var month = now.getMonth();//得到月份 var date = now.getDate();//得到日期 var day = now.getDay();//得到周几 var hour = now.get
代码如下: function getFormatDate() { var day=new Date(); var Year=0; var Month=0; var Day=0; var Hour = 0; var Minute = 0; var Second = 0; var CurrentDate=""; //初始化时间 Year = day.getFullYear(); Month = day.getMonth()+1; Day = day.getDate(); Hour = da
<script type="text/javascript"> var strdate = new Date(); var begindate = strdate.getTime(); var enddate = begindate + (-7*24*60*60*1000); strdate.setTime(enddate); var dtStart=new Date(strdate); </script>
js获取当前时间 //获取当前时间,格式YYYY-MM-DD function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) {