0

我用这个代码来显示时间

$in_Body .= 'Time: ' .  gmdate('F j, Y, h:i:s A') . "\n\n";

但我想按国家/地区显示时间,例如埃及

完整代码

<?php
$webmaster_mail = 'sales@elfnoon.com';
$redirect_page = 'elfnoon.com/';
$message_subject = 'رسالة من زائر لموقعك';
$in_Body ='';
foreach($_POST as $in_k=>$in_v) {
  $in_Body .="$in_k = $in_v\n\n";
}
$in_Body .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";
$in_Body .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$in_Body .= 'Time: ' .  gmdate('F j, Y, h:i:s A') . "\n\n";
mail(trim($webmaster_mail), "$message_subject ", "$in_Body","From: " . trim($webmaster_mail));
header("Location: $redirect_page");
?>

任何想法???

4

2 回答 2

2

如果您想使用埃及时间,请查看date_default_timezone_set支持的时区列表

gmdate返回基于 GMT 时区的时间。埃及是UTC + 2。

于 2012-09-06T17:42:25.853 回答
0

在您的代码中设置时区:-

 ini_set('date.timezon','Europe/Brussels');  

或者试试这个

<?php

ini_set('date.timezon','Europe/Brussels');
$webmaster_mail = 'sales@elfnoon.com';
$redirect_page = 'elfnoon.com/';
$message_subject = '????? ?? ???? ??????';
$in_Body ='';
foreach($_POST as $in_k=>$in_v) {
  $in_Body .="$in_k = $in_v\n\n";
}
$in_Body .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";
$in_Body .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
$in_Body .= 'Time: ' .  gmdate('F j, Y, h:i:s A') . "\n\n";
mail(trim($webmaster_mail), "$message_subject ", "$in_Body","From: " . trim($webmaster_mail));
header("Location: $redirect_page");
?>
于 2012-09-06T17:43:56.817 回答