Reputation: 984
My php web servers timezone is EDT (Eastern Day Light Time (US)). My current timezone is GMT+05.30. I need to enter current timestamp into my mysql database with the timestamp in my current timezone. By the way, I'm using a free php web server for my use. So I will not be having any previleges for modifying the server. Can some one suggest me some way of converting it to my GMT+05.30 from EDT in php using any script.Thanks in advance.
Upvotes: 0
Views: 1012
Reputation: 5119
Have a look at the following example
$timezone = new DateTimeZone('Europe/Berlin');
$date = new DateTime('@' . $yourTimestamp, $timezone);
echo $date->format('c');
So through the DateTimeZone Object your Time will be formatted by the DateTime object.
Upvotes: 3
Reputation: 946
I suggest you use the date_default_timezone PHP function. You can read about it here and here is the list of Supported Timezones
Example:
<?php
date_default_timezone_set('Europe/Amsterdam');
?>
Upvotes: 0