|
|
|
javascript จะทำการตั้งค่าเวลาให้ มันโชว์เวลาจากจาก sever จะทำยังไงคับ ผมเอามาใส่ใน php คับ |
|
|
|
|
|
|
|
Code (PHP)
<script type="text/JavaScript">
var serverdate=new Date('18 October 2009 21:14:23');
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=padlength(serverdate.getDate()) + " " + montharray[serverdate.getMonth()] + " " + serverdate.getFullYear()
var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=datestring+" "+timestring
}
var refresh_rate = 80;
function decrease_rate(){
refresh_rate = refresh_rate - 1;
document.getElementById("refreshrate").innerHTML=refresh_rate;
if(refresh_rate==0)
window.location.reload();
}
window.onload=function(){
setInterval("displaytime(),decrease_rate()", 1000);
MM_preloadImages('images/x1_over.jpg','images/x2_over.jpg','images/x3_over.jpg');
}
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-10-20 16:03:12 |
By :
chaynuwong |
View :
1354 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้รึป่าวครับ ใช้ php ดึงเวลาจาก sever
Code (PHP)
<script type="text/JavaScript">
var serverdate=new Date('<?=date("d F Y H:i:s")?>');
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=padlength(serverdate.getDate()) + " " + montharray[serverdate.getMonth()] + " " + serverdate.getFullYear()
var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
document.getElementById("servertime").innerHTML=datestring+" "+timestring
}
var refresh_rate = 80;
function decrease_rate(){
refresh_rate = refresh_rate - 1;
document.getElementById("refreshrate").innerHTML=refresh_rate;
if(refresh_rate==0)
window.location.reload();
}
window.onload=function(){
setInterval("displaytime(),decrease_rate()", 1000);
MM_preloadImages('images/x1_over.jpg','images/x2_over.jpg','images/x3_over.jpg');
}
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
|
|
|
|
|
Date :
2009-10-20 16:33:47 |
By :
lozomac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จำได้ว่าเคยโพสท์ไปแล้วครึ่งหนึ่ง
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=tis-620" />
<meta name="author" content="Marosdee" />
<script type="text/javascript">
var currenttime = '<?php echo date('F j, Y H:i:s'); ?>';
var d=new Date(currenttime);
function displaytime()
{
d.setSeconds(d.getSeconds()+1);
var s=d.getSeconds();
var m=d.getMinutes();
var h=d.getHours();
var day=d.getDay();
var date=d.getDate();
var month=d.getMonth();
var year=d.getFullYear();
var days=new Array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัส","ศุกร์","เสาร์");
var months=new Array('มกราคา','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม');
var date;
var time;
if (s<10) {s="0" + s}
if (m<10) {m="0" + m}
//if (h>12) {h-=12;am_pm = "pm"}
//else {am_pm="am"}
if (h<10) {h="0" + h}
date = "วัน" + days[day] + " ที่ " + date + " " + months[month] + " " + year;
time = "เวลา " + h + ":" + m + ":" + s;
document.getElementById("clock").innerHTML = date + '<br />' + time;
setTimeout(displaytime,1000);
}
window.onload = function()
{
displaytime();
}
</script>
<title>แสดงเวลา</title>
</head>
<body>
<div id="clock">กำลังโหลด...</div>
</body>
</html>
|
|
|
|
|
Date :
2009-10-20 18:05:33 |
By :
danya |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณคับ
|
|
|
|
|
Date :
2009-10-21 15:19:19 |
By :
chaynuwong |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|