How can we convert the time zones using PHP?



How can we convert the time zones using PHP?..

Answer / vijaya

By using date_default_timezone_get and
date_default_timezone_set function on PHP 5.1.0
// Discover what 8am in Tokyo relates to on the East Coast
of the US

// Set the default timezone to Tokyo time:
date_default_timezone_set('Asia/Tokyo');

// Now generate the timestamp for that particular timezone,
on Jan 1st, 2000
$stamp = mktime(8, 0, 0, 1, 1, 2000);

// Now set the timezone back to US/Eastern
date_default_timezone_set('US/Eastern');

// Output the date in a standard format (RFC1123), this will
print:
// Fri, 31 Dec 1999 18:00:00 EST
echo '

', date(DATE_RFC1123, $stamp) ,'
';?>

Is This Answer Correct ?    13 Yes 6 No

Post New Answer

More PHP Interview Questions

What is the diffrence between GET,POST and REQUEST Method.

7 Answers   Acquity Software,


How to delete cookie files on your computer?

0 Answers  


Why do we use cookie?

0 Answers  


Tell me what is the difference between the functions strstr() and stristr()?

0 Answers  


Which php framework is best for security?

0 Answers  






How do I stop php artisan serve in windows?

0 Answers  


How many types of array supported in php?

0 Answers  


how prepare the testing documentation.

0 Answers   Accenture,


How to remove the new line character from the end of a text line?

0 Answers  


Explain what are the two main string operators?

0 Answers  


What is PEAR in PHP?

3 Answers  


What is php used for?

0 Answers  


Categories