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 meant by an associative array?

0 Answers  


Explain the value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?

0 Answers  


What is .htaccessfile and use of this file

5 Answers  


What is the super method?

0 Answers  


How can you execute php script from the command line?

0 Answers  


I have 10 elements of Array, how can i remove 5 array element, with single function.

13 Answers  


what is the maximum size of databasi in mysql?

4 Answers  


Write a program to find the factorial of a number in php?

0 Answers  


How can I embed a java programme in PHP file and what changes have to be done in PHP.ini file?

1 Answers   Sify, Small Biz Express,


Why php is used with mysql?

0 Answers  


I went to an php interview yesterday.I got selected there.But,They asked me to sign bond by submitting my certificates for 2 years.Is it good or bad

7 Answers  


What is the current stable version of php? What advance thing in php7?

0 Answers  


Categories