php 动态时钟

2019-11-21 834 阅读 0评论

<?php
error_reporting(0); //抑制所有错误信息
header("content-Type: text/html; charset=utf-8"); //语言强制
$stime = date("Y-n-j H:i:s")." &nbsp;星期" . mb_substr( "日一二三四五六",date("w"),1,"utf-8" );

//ajax调用实时刷新
if ($_GET['act'] == "rt")
{

$arr=array('stime'=>"$stime");
$jarr=json_encode($arr);
echo $_GET['callback'],'(',$jarr,')';
exit;
}
?>
<script language="JavaScript" type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){getJSONData();});
function getJSONData()
{
setTimeout("getJSONData()", 1000);
$.getJSON('?act=rt&callback=?', displayData);
}
function displayData(dataJSON)
{
$("#stime").html(dataJSON.stime);
}
-->
</script>
<span id="stime"><?php echo $stime;?></span>

发表评论

快捷回复: 表情:
Addoil Applause Badlaugh Bomb Coffee Fabulous Facepalm Feces Frown Heyha Insidious KeepFighting NoProb PigHead Shocked Sinistersmile Slap Social Sweat Tolaugh Watermelon Witty Wow Yeah Yellowdog
提交
评论列表 (有 0 条评论, 834人围观)