我使用此代码显示时间
$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");
?>
任何想法???
答案 0 :(得分:2)
如果您想使用埃及时间,请查看date_default_timezone_set和the list of supported timezones。
gmdate 根据GMT时区返回时间。埃及是UTC + 2。
答案 1 :(得分: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");
?>