I am using yii framework
I am using below to code to get time
<?php echo date('Y/m/d H:i:s') ?>
how can i current time of UAE
?
United Arab Emirates Standard Time or UAE Standard Time is the time zone for the UAE. It is given by Gulf Standard Time, being 4 hours ahead of GMT/UTC (UTC+04:00) and is co-linear with neighbouring Oman.
The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts. To change the PHP timezone for an app, create a .user.ini file in the app's public directory with the following contents: date.timezone = America/Los_Angeles.
It's really simple to convert a DateTime from one time zone to another in PHP. Just create a DateTime object using date & time to be converted as the first parameter and the original time zone as the second parameter. Then change the time zone to the desired one using the setTimezone method. That's all!
Try this:
$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');
Use date_default_timezone_set() :
date_default_timezone_set('Asia/Dubai');
echo "The time is " . date('Y/m/d H:i:s');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With