Solved

php : time transformations

Posted on 2011-09-25
5
249 Views
Last Modified: 2012-05-12
Hello experts
I have a server hosted in US.

When I use: date("Y-m-d H:i");
It returns the local server time which is GMT-5

My question is : how can I get the time from Paris (+1 hour) ?
Regards
0
Comment
Question by:yarekGmail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 8

Accepted Solution

by:
Rik-Legger earned 500 total points
ID: 36595358
Put this in front of your code:

date_default_timezone_set('Europe/Paris');

Open in new window


http://php.net/manual/en/function.date-default-timezone-set.php
http://www.php.net/manual/en/timezones.europe.php
0
 
LVL 9

Expert Comment

by:Mahdi78
ID: 36595361
Use this code


<?
$timezone  = +1; //(GMT +1:00)
echo gmdate("Y/m/j H:i:s", time() + 3600*($timezone+date("I")));
?>

Open in new window

0
 
LVL 17

Expert Comment

by:psimation
ID: 36595377
Have a look here: http://www.php.net/manual/en/function.date.php

specifically at the Timezone section:

Timezone       ---       ---
e       Timezone identifier (added in PHP 5.1.0)       Examples: UTC, GMT, Atlantic/Azores
I (capital i)       Whether or not the date is in daylight saving time       1 if Daylight Saving Time, 0 otherwise.
O       Difference to Greenwich time (GMT) in hours       Example: +0200
P       Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)       Example: +02:00
T       Timezone abbreviation       Examples: EST, MDT ...
Z       Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.       -43200 through 50400

You can also have a look here: http://www.php.net/manual/en/function.date-default-timezone-set.php
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 36595444
Rik-Legger is correct.  This article explains how it all works.  See the first code snippet.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse engineer .sql from php files 11 54
SQL querys that gives me from one table into another. 2 41
Php logic to add to date card 9 39
php error 27 61
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question