|
 |
|
เขียน code อย่างไร ให้เห็น เวลาที่เหมือนกันทั่วโลก ครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
putenv("TZ=Asia/Tokyo");
echo "Tokyo Time: ". date("h:i:s")."\n";
?>
|
 |
 |
 |
 |
Date :
2009-09-12 16:02:47 |
By :
ebuzzz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2009-09-12 16:52:06 |
By :
nilas |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$dtBkk = mktime(gmdate("H") + 7, gmdate("i") + 0, gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y"));
$dtFormat = "Y-m-d H:i:s";
$dFormat = "Y-m-d";
$tFormat = "H:i:s";
$dtExpFormat = "D, d M Y H:i:s T";
เวลานำไปใช้ก็เลือกรูปแบบใดแบบหนึ่งที่ต้องการเช่น
$NowDate = date($dtFormat, $dtBkk);
จะได้ผลลัพธ์ เป็น 2009-09-12 17:54:15
|
 |
 |
 |
 |
Date :
2009-09-12 17:53:59 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมกำลังอยากได้อยู่พอดีกะทู้นี้มีประโยชน์มากคับ
|
 |
 |
 |
 |
Date :
2009-09-12 23:52:15 |
By :
nakait20 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
date_default_timezone_set('Asia/Bangkok');
|
 |
 |
 |
 |
Date :
2009-09-13 02:05:14 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นอย่างนี้ครับ คือผม จะ เอา code จาก net เป็น นาฬิกา แบบ อนาล็อก เค้า บอกว่า ถ้า อย่างได้เป็นเวลา ของ ประเทศ อะไรให้ ใส่ timezone เข้าไปนะ
Code (PHP)
<?php
// A PHP Analog Clock skin
// http://analogclock.caiphp.com/
require_once 'clock.php'; // Include the base analog clock script
$clock = new AnalogClock(128); // Create a 128x128 pixel clock
$clock->timezone =-5; // เค้าบอกว่า ถ้าใส่ค่า -5 จะเป็นเวลาของประเทศไทย แต่ ของเรา Timezone เป็น +7 ผมก็งง
/* These affect the way the clock looks */
$clock->Alias(TRUE); // Turn on anti-aliasing
$clock->Background('images/plain.png'); // Add a background image
/* The clock's hands */
$clock->NewHand('hour', 'line', '000000', 20, 3, TRUE);
$clock->NewHand('min', 'line', '000000', 35, 3, TRUE);
$clock->DrawOverlay('images/plain-overlay.png');
$clock->DrawPNG(); // Output as a PNG
?>
เค้าบอกว่า ถ้าใส่ค่า -5 จะเป็นเวลาของประเทศไทย แต่ ของเรา Timezone เป็น +7 ผมก็งง ทำไม จึงใส่ลบ เป็นของ ไทยนะครับ
|
 |
 |
 |
 |
Date :
2009-09-13 13:04:29 |
By :
nilas |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สรุปแล้ว ตอนนี้ ทำได้หรือไม่ได้ครับคุณ ลาชินิลาส
|
 |
 |
 |
 |
Date :
2009-09-13 19:48:48 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|