Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads | All Downloads

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Swish Templates
   SWiSH Climax
   GimpTalk
   Idea Designs
   Sposatoettore
   Try Acai Berry Diet
   Download Free Ringtones
   Swishzone

Manage your site with Flax Article Content Management System
Timezone, Tutorial PHP
Category : PHP / MySQL | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

This can be helpful :

Timezones By David Mytton on http://www.olate.com/

If you wanted to find out the data and time in Finland while your servers are in
Texas, then you can write your own functions using three functions already
available - mktime(), gmdate() and getdate().
We need to find out what the current GMT is, this is the standard to which all
timezones are compared. To do this, you use the gmdate() function which takes
exactly the same arguments as date(). You then increment the hour by the GMT
offset, which is passed to the function. The mktime() function automatically
compensates for any change in hour that also affects a change in ay/month/year.
The getdate() function is then used (which can optionally be passed a UNIX
timestamp created by the mktime function). This function will then return an array
with the following within it:

seconds
minutes
mday (day of the month)
wday (day of the week, numeric)
year
yday (day of the year, numeric)
weekday (text)
month (textual)
The following code will do this:

<?php

function worldtime($offset)
{
$day = gmdate("d");
$day = gmdate("m");
$day = gmdate("g");
$day = gmdate("y");
$day = gmdate("i");
$day = gmdate("s");
$day = gmdate("H") + $offset;

$tm_ar = getdate (mktime ( $hour,
$minutes,
$seconds,
$month,
$day,
$year));

return ($tm_ar);
}

$currdate = worldtime($offset);
?>

You then call this function passing it the GMT offset value, for our example

(Finland), it is 2:

<?php
$finland_date = worldtime(2);
?>

And that is it!


All rights reserved - swish-db.com