|
 |
|
เกี่ยวกับเวลาครับ ปรากฏว่า เวลาที่มันขึ้น มากกว่าเวลาเครื่องผมอยู่หนึ่งชั่วโมงมันเกิดจากอะไรเหรอครับ |
|
 |
|
|
 |
 |
|
ผมทำยังงี้ครับ
เขียนไฟล์ มา 1 ไฟล์ เก็บค่าวันที่ก่อน แบบนี้
Code (PHP) สมมติผมตั้งชื่อว่า datetime.php
$bkk=mktime(gmdate("H")+7,gmdate("i")+0,gmdate("s"),gmdate("m"),gmdate("d"),gmdate("Y"));
$datetimeformat = "H:i:s"; //รูปแบบ ชม:นาที:วินาที)
$datetimeformat2 = "Y-m-d";//รูปแบบ ปี/เดือน/วัน)
$datenow = date($datetimeformat2,$bkk);
$timenow = date($datetimeformat,$bkk); //ค่าเวลาปัจจุบันในเครื่อง SV = 07/08/2 - 23:24
จากนั้น ผมก็ include("datetime.php"); ในไฟล์ เอกสารใดๆ ที่ต้องการ
แล้ว เรียกตัวแปร $datenow และ $timenow เข้าไปใช้
เช่น
Code (PHP) showdate.php
echo"เวลาปัจจุบัน : $datenow,$timenow";
ลองดูครับ ^-^
|
 |
 |
 |
 |
Date :
2009-10-13 14:29:49 |
By :
yomaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
date_default_timezone_set('Asia/Bangkok');
echo date("d/m/Y H:i:s");
?>
|
 |
 |
 |
 |
Date :
2009-10-13 14:50:13 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จริงๆ ผมเคยลอง แบบ คห. ที่ 2 แล้วนะครับ แต่ก็ไม่ได้เหมือนเดิม ไม่รู้ทำไม
|
 |
 |
 |
 |
Date :
2009-10-13 14:56:18 |
By :
yomaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
support php5
|
 |
 |
 |
 |
Date :
2009-10-13 15:23:01 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับ
ผมก็ใช้ php5 อยู่อ่ะครับผม
|
 |
 |
 |
 |
Date :
2009-10-13 15:35:57 |
By :
yomaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมแก้ได้แล้วครับ
ดูจากลิงค์นี้ครับ
http://www.phplifestyle.com/63/php-5-%E0%B8%81%E0%B8%B1%E0%B8%9A%E0%B8%9B%E0%B8%B1%E0%B8%8D%E0%B8%AB%E0%B8%B2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B9%80%E0%B8%A7%E0%B8%A5%E0%B8%B2/
เขาว่า php5 จะเซตเวลามาเกินกว่าหนึ่งชั่วโมงครับ
|
 |
 |
 |
 |
Date :
2009-10-13 20:48:51 |
By :
nuttapont |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช่ครับ default timezone คือ Asia/Krasnoyarsk ก็เลยเร็วไป 1ชม.ครับ
เราสามารถเช็ตค่า default timezone ใน php.in ด้วยโซนเวลาอื่นก็ได้ครับ
date.timezone = Asia/Bangkok // อย่าลืมเอา ; ข้างหน้าออกด้วยน่ะ
ส่วนทำไมใช้ date_default_timezone_set('Asia/Bangkok'); ไม่ได้นั้นไม่ทราบเหมือนกัน ผมใช้มาหลายโฮสแล้วครับยังไม่มีปัญหา
|
 |
 |
 |
 |
Date :
2009-10-13 21:15:38 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
< ?
echo date('l jS \of F Y h:i:s A');
?>
|
 |
 |
 |
 |
Date :
2009-10-13 21:16:11 |
By :
tap |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ที่เครื่อง เซิกเวอร์ที่ใช้รันก็น่าจะหายนะคับ
|
 |
 |
 |
 |
Date :
2009-10-14 00:42:23 |
By :
siammbk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|