Last active
December 17, 2015 07:49
-
-
Save robinWongM/5575965 to your computer and use it in GitHub Desktop.
中考倒计时范例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // 以下代码仅供参考 | |
| $now = getdate(); //现在时间 | |
| $nowtime = mktime(0,0,0,$now['mon'],$now['mday'],$now['year']); //现在时间的Unix时间戳 | |
| $zhongkao = mktime(0,0,0,6,20,2013); //2013.6.20 | |
| $remaining = $zhongkao - $nowtime; //如果需要正数,则用$nowtime - $zhongkao | |
| $days = strval($remaining / 86400); //转换成天数,84600 = 60 * 60 * 24 | |
| $split = preg_split("//",$days,0,PREG_SPLIT_NO_EMPTY);//分割成组成数字的每一个数字,例如38分割成3和8 | |
| foreach($split as $number)//一个一个输出 | |
| { | |
| echo ('<img src="http://1.labcdn.sinaapp.com/cd/' . $number .'.png" />' . "\n"); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment