<!--demo.html中内容-->

<body>
<img id="time" src="test.php" />

<script>
setInterval(function(){
//让时间动起来
document.getElementById("time").src="test.php?"+Math.random();

},1000);
</script>
</body>

<!--test.php中内容-->

<?php
//获取系统时间,设置时区
date_default_timezone_set("PRC");

$h = date("H");
$i = date("i");
$s = date("s");

//1 创建资源(画布的大小)
$img = imagecreatetruecolor(200, 250);
//设置画布的颜色
$white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
$red = imagecolorallocate($img, 255, 0, 0);
$blue = imagecolorallocate($img, 0, 0, 0XFF);
$pink = imagecolorallocate($img, 0XFF, 0, 0XFF);
$green = imagecolorallocate($img, 0, 0xFF, 0);

imagefill($img, 0, 0, $white);
//2. 制作各种颜色
//画空心圆
imageellipse($img, 100, 100, 190, 190, $blue);
//画实心圆
imagefilledellipse($img, 100, 100, 4, 4, $blue);

imagestring($img, 3, 95, 8, "12", $blue);
imagestring($img, 3,180, 95, "03", $blue);
imagestring($img, 3, 95, 180, "06", $blue);
imagestring($img, 3, 11, 95, "09", $blue);

//秒针
$len = 80;

$a = $len*sin(pi()/30*$s);
$b = $len*cos(pi()/30*$s);
$x = 100 + $a;
$y = 100 - $b;

imageline($img, 100, 100, $x, $y, $red);

//数字的时间
imagestring($img, 5, 20, 230, "NOW: {$h}:{$i}:{$s}", $red);

//4保存,或输出给浏览, 写第二个参数就是保存
header("Content-Type:images/gif");
imagegif($img);

//5. 释放资源
imagedestroy($img);

最新文章

  1. Sass用法指南
  2. YTU 3026: 中序线索化二叉树
  3. git 较基础命令
  4. 为mongodb加用户授权并使用RockMongo进行管理
  5. CSS特性: 继承 和 层叠
  6. Intellij编译时报“java: System Java Compiler was not found in classpath”
  7. Android or iOS 运行 meteor App 屏幕一片空白 White screen的解决方法
  8. Python 读取文件下所有内容、获取文件名、截取字符、写回文件
  9. cognos8.3 sample在DB2里的安装
  10. PHP无限极分类生成树方法
  11. perl 线程创健
  12. angularjs填写表单
  13. 17 java 存在的问题(转)
  14. ionic的弹出框$ionicPopover
  15. nginx libpcre.so.1: cannot open shared object file
  16. EF 利用PagedList进行分页并结合查询 方法2
  17. 洛谷 P1057 传球游戏 解题报告
  18. Boot-col-sm布局
  19. 关于hibernate总是报错 配置factory的id找不到,mapping配置文件Could not parse mapping document from input stream
  20. 【C#】C#学习笔记_1

热门文章

  1. hihoCoder #1068 : RMQ-ST算法(模板)
  2. Ubuntu16.04下使用sublime text3搭建Python IDE
  3. vue实现微信分享朋友圈和朋友功能
  4. table 会有默认的外边框,内部会有分割线
  5. CentOS 7.0关闭防火墙
  6. 浅谈倍增LCA
  7. 四. python网络编程
  8. (34)zabbix Queue队列
  9. tkinter学习-滚动条
  10. syslog命令