user2505513
user2505513

Reputation: 333

PHP adjust time zone for date

The following output on my website is -1 hr, and I just wanted a quick fix to adjust it accordingly, but I'm not sure of the correct syntax...

<?php echo date('D, jS F @ g:ia', strtotime($row->datetime)); ?>

Upvotes: 3

Views: 6390

Answers (2)

Rajeev Ranjan
Rajeev Ranjan

Reputation: 4142

set default time zone

$timezone = 'America/Los_Angeles';
$stored_time = '2011-01-30 18:23:49';

date_default_timezone_set($timezone);
$timestamp = strtotime($stored_time);
$local_time = $timestamp + date('Z');
$local_date = date('Y-m-d H:i:s', $local_time);

echo $local_date;

Upvotes: 2

Code Lღver
Code Lღver

Reputation: 15593

Use the date_default_timezone_set function of PHP to set the your timezone as default it is taking the timezone of server.

Here is the list of timezones.

Upvotes: 4

Related Questions