如题所述
第1个回答 2011-12-14
<?php
function weekday()
{
$i=date('w') ;
switch ($i)
{
case 0: $str = "星期日"; break;
case 1: $str = "星期一"; break;
case 2: $str = "星期二"; break;
case 3: $str = "星期三"; break;
case 4: $str = "星期四"; break;
case 5: $str = "星期五"; break;
case 6: $str = "星期六"; break;
}
return $str;
}
echo weekday();
?>
申明,这个获取的时间,是服务器上的时间。
如果你要获取本地的时间,建议你采用js代码实现。
function weekday()
{
$i=date('w') ;
switch ($i)
{
case 0: $str = "星期日"; break;
case 1: $str = "星期一"; break;
case 2: $str = "星期二"; break;
case 3: $str = "星期三"; break;
case 4: $str = "星期四"; break;
case 5: $str = "星期五"; break;
case 6: $str = "星期六"; break;
}
return $str;
}
echo weekday();
?>
申明,这个获取的时间,是服务器上的时间。
如果你要获取本地的时间,建议你采用js代码实现。
第2个回答 2011-12-13
<?php
02 function getWeekName($data,$format = '星期')
03 {
04 $week = date( "D ",$data);
05 switch($week)
06 {
07 case "Mon ":
08 $current = $format."一";
09 break;
10 case "Tue ":
11 $current = $format."二";
12 break;
13 case "Wed ":
14 $current = $format."三";
15 break;
16 case "Thu ":
17 $current = $format."四";
18 break;
19 case "Fri ":
20 $current = $format."五";
21 break;
22 case "Sat ":
23 $current = $format."六";
24 break;
25 case "Sun ":
26 $current = $format."日";
27 break;
28 }
29 return $current;
30 }
31
32
33 echo '今天是:'.getWeekName(time(),'星期');
34 echo '<br>';
35 echo '今天是:'.getWeekName(time(),'礼拜');
36 echo '<br>';
37 echo '2010-12-12是:'.getWeekName(strtotime('2010-12-12'),'礼拜');
38 ?>
02 function getWeekName($data,$format = '星期')
03 {
04 $week = date( "D ",$data);
05 switch($week)
06 {
07 case "Mon ":
08 $current = $format."一";
09 break;
10 case "Tue ":
11 $current = $format."二";
12 break;
13 case "Wed ":
14 $current = $format."三";
15 break;
16 case "Thu ":
17 $current = $format."四";
18 break;
19 case "Fri ":
20 $current = $format."五";
21 break;
22 case "Sat ":
23 $current = $format."六";
24 break;
25 case "Sun ":
26 $current = $format."日";
27 break;
28 }
29 return $current;
30 }
31
32
33 echo '今天是:'.getWeekName(time(),'星期');
34 echo '<br>';
35 echo '今天是:'.getWeekName(time(),'礼拜');
36 echo '<br>';
37 echo '2010-12-12是:'.getWeekName(strtotime('2010-12-12'),'礼拜');
38 ?>
第3个回答 2011-12-13
<?php
print_r(date('D'));
print_r(date('l'));
?>
可以得到英文的周,上面是缩写,下面是全称。本回答被网友采纳
print_r(date('D'));
print_r(date('l'));
?>
可以得到英文的周,上面是缩写,下面是全称。本回答被网友采纳