关于PHP获取时间显示的问题

WBOY
Release: 2016-06-23 13:39:52
Original
981 people have browsed it


如图所示  小时指针位置 错误    看了下代码  不知道什么地方错 了  求各位大大分析下
date_default_timezone_set('Asia/Shanghai');
$h = date("H");
$m = date("i");
$s = date("s");
....
        $seclen=80;//秒针长度
$seca=$seclen*sin(pi()/30*$s);
$secb=$seclen*cos(pi()/30*$s);
$secx=120+$seca;
$secy=120-$secb;
imageline($timeimg,120,120,$secx,$secy,$red);

$minlen=70;//分针长度
$mina=$minlen*sin(pi()/30*$m);
$minb=$minlen*cos(pi()/30*$m);
$minx=120+$mina;
$miny=120-$minb;
imageline($timeimg,120,120,$minx,$miny,$black);

$hourlen=50;//时针长度
$houra=$hourlen*sin(pi()/30*$h);
$hourb=$hourlen*cos(pi()/30*$h);
$hourx=120+$houra;
$houry=120-$hourb;
imageline($timeimg,120,120,$hourx,$houry,$black);


回复讨论(解决方案)

有jQuery这个东东,为啥还用php来跑,,,,

$mina=$minlen*sin(pi()/30*$m);
$houra=$hourlen*sin(pi()/30*$h);

时和分秒一个12进制,一个60进制,但是求坐标的算法居然一样,肯定是这里的问题
将$h翻5倍再进入计算就对了吧

有jQuery这个东东,为啥还用php来跑,,,,


因为在看PHP GD库  知道怎么用JQ实现动态显示  只是 想用这个试一下而已

$mina=$minlen*sin(pi()/30*$m);
$houra=$hourlen*sin(pi()/30*$h);

时和分秒一个12进制,一个60进制,但是求坐标的算法居然一样,肯定是这里的问题
将$h翻5倍再进入计算就对了吧


谢谢啦    自己蠢了  一下子找不到头了    哈哈哈  
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!