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 would occur if a fatal error was thrown in your php program?

0 Answers  


What are major variables in research?

0 Answers  


What are the different components used in php for formatting?

0 Answers  


Tell me what should we do to be able to export data into an excel file?

0 Answers  


What does $_ post mean in php?

0 Answers  






Tell me how is it possible to know the number of rows returned in result set?

0 Answers  


What is php and sql?

0 Answers  


How to block direct directory access in PHP?

0 Answers  


What is cms php?

0 Answers  


What are the string functions in php?

0 Answers  


What is the most convenient hashing method to be used to hash passwords?

0 Answers  


How many types of arrays are there in php?

0 Answers  


Categories