Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > โค้ดเวลา สำหรับทำเว็บประมูล อยากแก้ให้เป็นรุปแบบ วัน : ชม : นาที : วินาที ครับ



 

โค้ดเวลา สำหรับทำเว็บประมูล อยากแก้ให้เป็นรุปแบบ วัน : ชม : นาที : วินาที ครับ

 



Topic : 077005



โพสกระทู้ ( 156 )
บทความ ( 0 )



สถานะออฟไลน์




ของผมลองนำโค้ดนี้มาศึกษา แต่ จะแก้ให้เป็น D : H : M : S ไม่ทราบว่าทำอย่างไรรบกวนผู้รู้แนะนำหน่อยครับ

Code (PHP)
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<form name="form1" method="post" action="test.php">
<table width="100%" cellspacing="0" cellpadding="0">
<tr> 
<td><table cellspacing="1" cellpadding="1">
<tr> 
<td width="73"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">&nbsp;</font></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">วันที่</font></div></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เดือน</font></div></td>
<td width="58"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">ปี 
( พ.ศ. )</font></div></td>
<td width="47"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">ชั่วโมง</font></div></td>
<td width="41"><div align="center"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">นาที</font></div></td>
</tr>
<tr> 
<td height="26"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เวลาเริ่มกิจกรรม</font></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="start_d" id="start_d">
<option value="0">เลือก</option>
<?
for($d=1;$d<=31;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="start_m" id="start_m">
<option value="0">เลือก</option>
<?
for($d=1;$d<=12;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="start_y" id="select2">
<option value="0">เลือก</option>
<?
$Tyear=date("Y")+544; 
for($d=2555;$d<=$Tyear;$d++)
{
?>
<option value="<? echo $d-544; ?>"><? echo "พ.ศ. ".$d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="start_h" id="start_h">
<option value="0">0</option>
<?
for($d=1;$d<=24;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
: </font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="start_M" id="select">
<option value="0">00</option>
<?
for($i=1;$i<=59;$i++)
{
?>
<option value="<? echo $i; ?>"><? echo $i; ?></option>
<?
}
?>
</select>
</font></strong></td>
</tr>
<tr> 
<td height="26"><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif">เวลาจบกิจกรรม</font></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="end_d" id="end_d">
<option value="0">เลือก</option>
<?
for($d=1;$d<=31;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="end_m" id="end_m">
<option value="0">เลือก</option>
<?
for($d=1;$d<=12;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="end_y" id="end_y">
<option value="0">เลือก</option>
<?
for($d=2555;$d<=$Tyear;$d++)
{
?>
<option value="<? echo $d-544; ?>"><? echo "พ.ศ. ".$d; ?></option>
<?
}
?>
</select>
</font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="end_h" id="end_h">
<option value="0">0</option>
<?
for($d=1;$d<=24;$d++)
{
?>
<option value="<? echo $d; ?>"><? echo $d; ?></option>
<?
}
?>
</select>
: </font></strong></td>
<td><strong><font size="2" face="Microsoft Sans Serif, MS Sans Serif, sans-serif"> 
<select name="end_M" id="select">
<option value="0">00</option>
<?
for($i=1;$i<=59;$i++)
{
?>
<option value="<? echo $i; ?>"><? echo $i; ?></option>
<?
}
?>
</select>
</font></strong></td>
</tr>
<tr>
<td height="26" colspan="6"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>





Code (PHP)
<?php

function DateToTimestamp($date_){

// เป็นฟังก์ชั่น ที่จะทำวันเวลาไปเป็นฟังก์ชั่น mktime 

$sh_=explode("/",$date_);

$Sec_=date("s");

$timeStamp_=mktime($sh_[3],$sh_[4],$Sec_,$sh_[1],$sh_[0],$sh_[2]);

return $timeStamp_;

}
$show_start=$start_d."/".$start_m."/".$start_y."/".$start_h."/".$start_M; //นำค่าวันเวลาที่ เริ่มต้นมาเก็บไว้ในตัวแปร 
$timestamp=DateToTimestamp($show_start);//แปลงค่าให้เป็นฟังก์ชั่น mktime 
$show_end=$end_d."/".$end_m."/".$end_y."/".$end_h."/".$end_M;//นำค่าวันเวลาที่ สิ้นสิ้นมาเก็บไว้ในตัวแปร 
$timestampa=DateToTimestamp($show_end);//แปลงค่าให้เป็นฟังก์ชั่น mktime 
$test=$timestampa-$timestamp; //นำเวลาเริ่ม กับสิ้นสุดมาลบกันก็จะได้เวลา ที่จะนับถ้อยหลัง 
$num=$test;
$s=date("s",$num);
$m=$num/60;
echo $test=$m.":".$s;
?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body onLoad="begintimer()">
<script language="">
var limit="<? echo $test; ?>"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function begintimer(){
if (!document.images)
return
if (parselimit==1)
// เหตุการณ์ที่ต้องการให้เกิดขึ้น
// window.location='page.php'; ถ้าต้องการให้กระโดดไปยัง Page อื่น
alert("Time Over");
else{ 
parselimit-=1
hour=Math.floor(parselimit/3600)
//curmin=(parselimit%3600)
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (hour!=0)
curtime="เวลาที่เหลือ <font color=red> "+hour+"ช.ม.<font color=red>"+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที "
else
if (curmin!=0)
curtime="เวลาที่เหลือ <font color=red> "+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที "
else
if(cursec==0)
{
alert('หมดเวลาแล้วจ้า');
}
else
{
curtime="เวลาที่เหลือ <font color=red>"+cursec+" </font>วินาที "
}
document.getElementById('dplay').innerHTML = curtime;
setTimeout("begintimer()",1000)
}
}
//-->
</script>
<div id=dplay ></div>
<form name="frmTest" action="check.php">

</form>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-04-12 16:10:15 By : showroom View : 1453 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

พวกเว็บประมูลน่าจะใช้ Ajax น่ะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-06-10 21:29:03 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : โค้ดเวลา สำหรับทำเว็บประมูล อยากแก้ให้เป็นรุปแบบ วัน : ชม : นาที : วินาที ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่