Home > php教程 > php手册 > 简单的PHP实现倒计时方法

简单的PHP实现倒计时方法

WBOY
Release: 2016-06-06 19:46:14
Original
2570 people have browsed it

/** * @todo Count Down (倒 计时 ) * @param String $endTime * @return String time * @example * $endTime = 2014-07-13 8:15:00;echo countDown($endTime); */function countDown($endTime){$endTime = strtotime($endTime);$beiginTime = strtotime(dat

	/**
	 * @todo Count Down (倒<strong>计时</strong>)
	 * @param String $endTime
	 * @return String time
	 * @example 
	 * 	$endTime = '2014-07-13 8:15:00';
		echo countDown($endTime);
	 */
	function countDown($endTime){
		$endTime = strtotime($endTime);
		$beiginTime = strtotime(date('Y-m-d H:i:s'));
		$timeDifference = $endTime - $beiginTime;
		switch ($timeDifference){
			case $timeDifference <br>
<p>该<strong>方法</strong>可以让整个计算在PHP后端计算并且输出一定的格式后直接在页面展示倒<strong>计时</strong>详细信息。</p>
<p>页面想要<strong>实现</strong>1秒自动刷新请配合ajax和定时器去进行局部刷新即可。</p>
<p>此处主要的是描述一个思路,至于怎么做好还是要看项目和具体的需求。</p>


Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template