时间差、星期、时间显示、学习记录

来源:互联网 发布:mysql 字段数值累加 编辑:程序博客网 时间:2024/05/17 23:06
8小时时间差解决:
date_default_timezone_set('Asia/Chongqing');$currentTime = date("H:i:s");
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;">//大陆内地可用的值是:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi ,PRC(依次为重庆,上海,乌鲁木齐,中华人民共和国)</span>


1.显示中文星期的函数:<?phpdate_default_timezone_set('asia/shanghai');echo '今天是'. date('Y年m月d日 '). ' 星期' . cnWeek(date('Y-M-d'));function cnWeek($date){  $arr = array('天','一','二','三','四','五','六');  return $arr[date('w',strtotime($date))];}?>2.让时间一直走,一般使用javascript来完成,以下是代码:<html><head><title>当前时间js脚本,sky整理收集,站长特效欢迎您。</title></head><script language='JavaScript'>  var timerID = null;  var timerRunning = false;  function stopclock ()  {    if(timerRunning)      clearTimeout(timerID);      timerRunning = false;  }  function startclock ()   {    stopclock();    showtime();  }  function showtime () {    var now = new Date();    var hours = now.getHours();    var minutes = now.getMinutes();    var seconds = now.getSeconds()    var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )    timeValue += ((hours >12) ? hours -12 :hours)    timeValue += ((minutes < 10) ? ":0" : ":") + minutes    timeValue += ((seconds < 10) ? ":0" : ":") + seconds    document.clock.thetime.value = timeValue;    timerID = setTimeout("showtime()",1000);    timerRunning = true;  }</script><body onload=startclock()><form name="clock"><input name="thetime" style="font-size: 9pt;color:#000000;border:0px none; " size="12" /></form></body></html>

0 0
原创粉丝点击