[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php : time transformations

Posted on 2011-09-25
5
Medium Priority
?
253 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 2000 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 111

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

656 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