php时间戳函数实现计算第几周,以及当天所在周的具体日期范围

<wbr><p><span style="font-family:宋体">&lt;html&gt;<br> &lt;script language="javascript"&gt;<br> function showdate(){<br> c = new Date(2008,1,29);//输入开学的日期.注意,月份是从0-11;<br> comper=c.getTime();//以2008年2月29日作为上半学期结束。然后记录新的开学日期<br> var now= new Date();//获取当前时间<br> var d_now=now.getTime();//获取当前时间秒数<br> if (d_now &gt; comper)<br> {d = new Date(2008,2,3);}<br> else d = new Date(2007,8,3);//输入开学的日期.注意,月份是从0-11;<br> d_start=d.getTime();//获取时间秒数,具体见手册</span></p> <p><span style="font-family:宋体">//document.write(d_start);<br> var now= new Date();//获取当前时间<br> var d_now=now.getTime();//获取当前时间秒数<br> //document.write(d_now);<br> var Week_num =(d_now-d_start)/604800000;//3600,000毫秒*24*7=604800000<br> if((d_now-d_start)%604800000)<br> {<wbr> Week_num = Week_num+1;<br> }<br> else<br> {<br> }<br> Week_num= Math.floor(Week_num);<br> document.write("&lt;/b&gt;&lt;font color=red&gt; 第" + Week_num + "周&lt;/font&gt;");</wbr></span></p> <p><span style="font-family:宋体">//return(Week_num);<br> }<br><wbr></wbr></span></p> <p><span style="font-family:宋体"><br> &lt;/script&gt;<br> &lt;?<br> //计算今天是开学第几周<br> function Show_week(){<br> $now_time=time();//获取今天的时间戳<br> $compar = 1204214400;//hour,minute,second month,day,year,is_dst<br> //上半学期的结束时间<br> if($now_time&gt;$compar)<br> {<br> $start_time = 1204473600;//时间戳,秒数2008,3,3);<br> }//下学期时间<br> else<br> {<wbr><br> $start_time = 1188748800;//2007.9.3<br> }//上学期开学时间<br> $Week_num =($now_time-$start_time)/604800;//3600,000毫秒*24*7=604800000<br> //echo $start_time;<br> if(($now_time-$start_time)%604800)<br> {<wbr> $Week_num = $Week_num+1;<br> }<br> else<br> {<br> }<br> $Week_num = floor($Week_num);</wbr></wbr></span></p> <p>return($Week_num);<br> }</p> <p>//计算当天所在周的范围<br> function Week_date(){//此处考虑到放假没有人使用,所以没有考虑跨年的日期改变<br> $now=getdate();//获取当前时间组<br> $Week_day=$now[weekday];//日<br> $Now_Time=time();<br> //echo $Now_Time;<br> //echo $Week_day;<br> switch($Week_day){<br><wbr> case Monday:<br><wbr><wbr><wbr> // echo "1";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time;<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(6*24*60*60);<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> // 6 days; 24 hours; 60 mins; 60secs<wbr> 以后依次类推<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Tuesday:<br><wbr><wbr><wbr><wbr><wbr> echo "2";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time-(1*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(5*24*60*60);<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Wednesday:<br><wbr><wbr><wbr> // echo "3";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time1-(2*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(4*24*60*60);<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Thursday:<br><wbr><wbr><wbr> // echo "4";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time-(3*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(3*24*60*60);<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Friday:<br><wbr><wbr><wbr> // echo "5";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time-(4*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(2*24*60*60);<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Saturday:<br><wbr><wbr><wbr><wbr> //echo "6";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time-(5*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time+(1*24*60*60);<br><wbr><wbr><wbr><wbr> break;<br><wbr> case Sunday ;<br><wbr><wbr><wbr><wbr> //echo "7";<br><wbr><wbr><wbr><wbr> $Last_time=$Now_Time-(6*24*60*60);<br><wbr><wbr><wbr><wbr> $Next_time=$Now_Time;<br><wbr><wbr><wbr><wbr> break;<br> }<br> //echo $Last_time;<br> //echo $Next_time;<br><wbr>$Last_time1=date('Y年m月d日', $Last_time);<br> $Next_time1=date('Y年m月d日', $Next_time) ;<br> $week_rs = "$Last_time1 ~ $Next_time1";<br> return($week_rs);<br> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></p> <p>?&gt;<br> &lt;/html&gt;<br></p> </wbr>

你可能感兴趣的:(PHP)