Skip to content

PHP Programming

Converting Between Timezones

PHP comes with an in-built function to display time in your required format, but what if you want to display date and time according to user’s timezone, that’s where PEAR package Date comes in. Let’s see how we can convert a date in GMT to IST.

// print server time
echo "Local time is " . $d->format("%A, %d %B %Y %T") . "n";
// convert to IST
// output converted date/time
echo "Destination time is " . $d->format("%A, %d %B %Y %T");
Be Sociable, Share!
    The following two tabs change content below.

    One Trackback

    1. $1000 Welcome Bonus!

    Add Your Comment (Get a Gravatar)