phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Date Time: Converting Between Different Time Zones

Tag: date, time, time zone   Category: PHP Basic
post: 21 Mar 2008 read: 606


PHP Date Time Tips - Part 13: Do you want to know the local time in another time zone? Write a PHP function to calculate the time in the specified zone. Like this:

<?
function getLocalTime($tm, $offset){
  return ($tm - date("Z", $tm)) + (3600 * $offset);
}

// get current local time in Singapore
echo date("H:i:s d-m-y", getLocalTime(mktime(), 8)). "<br>";

// get current local time in bangkok
echo date("H:i:s d-m-y", getLocalTime(mktime(), 7)). "<br>";

// get current local time in USA (Pasific)
echo date("H:i:s d-m-y", getLocalTime(mktime(), -8)). "<br>";
?>


Series this article:
PHP Date Time: Getting Current
PHP Date Time: Checking Date Validity
PHP Date Time: Formating Timestamp
PHP Date Time: Converting Strings to Timestamps
PHP Date Time: Using English-language time descriptors
PHP Date Time: Checking Leap Years
PHP Date Time: Finding The Number of Days in a Month
PHP Date Time: Finding the Day in Year Number for a Date
PHP Date Time: Finding The Number of Weeks in Year Number for a Date
PHP Date Time: Finding the Day Name for a Date
PHP Date Time: Finding The Total Number of Days in Year
PHP Date Time: Finding The Total Number of Weeks in Year
PHP Date Time: Converting Local Time to GMT
PHP Date Time: Converting Between Different Time Zones
PHP Date Time: Finding the Year Quarter for a Date
PHP Date Time: Converting Minutes to Hours
PHP Date Time: Comparing Dates

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting