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.
setTZByID("GMT"); // print server time echo "Local time is " . $d->format("%A, %d %B %Y %T") . "n"; // convert to IST $d->convertTZByID("PST"); // output converted date/time echo "Destination time is " . $d->format("%A, %d %B %Y %T"); ?>
Latest posts by Alex Shaw (see all)
- The Importance Of Objective C in iPhone and IDE Applications - October 25, 2011
- Amazon EC2 Paves the Way in Hosting - October 17, 2011
- New Improvements in Developer Tools in Linux Programming - October 12, 2011