首頁 >php教程 >PHP源码 >获取当天或某个日期是星期几

获取当天或某个日期是星期几

PHP中文网
PHP中文网原創
2016-05-25 17:14:50946瀏覽

1. [代码][PHP]代码  

<?php
function getWeekName($data,$format = &#39;星期&#39;)
{
	$week   =  date( "D ",$data); 
	switch($week) 
	{ 
		case "Mon ": 
			$current   =   $format."一"; 
			break; 
		case "Tue ": 
			$current   =   $format."二"; 
			break; 
		case "Wed ": 
			$current   =   $format."三"; 
			break; 
		case "Thu ": 
			$current   =   $format."四"; 
			break; 
		case "Fri ": 
			$current   =   $format."五"; 
			break; 
		case "Sat ": 
			$current   =   $format."六"; 
			break; 
		case "Sun ": 
			$current   =   $format."日"; 
			break; 
	} 
	return $current;
}


echo &#39;今天是:&#39;.getWeekName(time(),&#39;星期&#39;);
echo &#39;<br>&#39;;
echo &#39;今天是:&#39;.getWeekName(time(),&#39;礼拜&#39;);
echo &#39;<br>&#39;;
echo &#39;2010-12-12是:&#39;.getWeekName(strtotime(&#39;2010-12-12&#39;),&#39;礼拜&#39;);
?>

                   

                   

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn