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