njnjnj
njnjnj

Reputation: 984

Converting from EDT to GMT+05.30 time zone in php for entering timestamp in mysql database

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

Answers (3)

vashu tyagi
vashu tyagi

Reputation: 1

Use this:

echo gmdate("Y:F:l     h:i:s",time()+19800);

Upvotes: 0

Marcel
Marcel

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

Takoyaro
Takoyaro

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

Related Questions