簡體   English   中英

如何在PHP中獲取阿聯酋的當前時間

[英]how to get current time of a UAE in PHP

我正在使用yii框架

我正在使用下面的代碼來獲取時間

<?php echo date('Y/m/d H:i:s') ?>

我現在幾點UAE

嘗試這個:

$tz = 'Asia/Dubai'; // your required location time zone.
$timestamp = time();
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp
echo $dt->format('Y/m/d H:i:s');

使用date_default_timezone_set()

date_default_timezone_set('Asia/Dubai');
echo "The time is " . date('Y/m/d H:i:s');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM