Take the 2-minute tour ×

I have a time that is being sent to me in UTC time, but I want to adjust it so its the outer edges of the days on East Coast time (EST/EDT). That is, I want the user to be able to enter in EDT/EST centric dates, and have it query with the UTC correct dates.

$start_date and $end_date are MM/DD/YYYY formatted dates passed via a GET variable.

 $start_date = date('Y-m-d 00:00:00', $start_date);
 $end_date = date('Y-m-d 23:59:59', $end_date);

These dates are for use in a database query, whose times are stored in UTC time.

So, I want the start date to be the day before at 8pm or 7pm, depending on daylight savings, and then to end at 7:59:59 or 6:59:59, again depending on daylight savings.

How would I do that?

share|improve this question
Which database are you using? Postgres for example has a field type called "timestamp with time zone" that does exactly what you're looking for. The database would take care of all your timezone conversions. –  Kenaniah May 28 '10 at 23:27
Have you checked date_default_timezone_set() function ? –  Serty Oan Jun 3 '10 at 16:19
add comment

2 Answers

If you know what timezone the data is coming from, you can do something like this:

$userTimezone = new DateTimeZone('America/New_York');


return $ts->format('Y-m-d H:i:s');

Where $datetime is a valid date format according to thse rules - http://www.php.net/manual/en/datetime.construct.php

This is the core of what we do in web2project - http://web2project.net/ - to get a datetime in the users' selected timezone but store it in GMT/UTC.

share|improve this answer
add comment

In MySQL you can do the following:

SELECT * FROM tablename WHERE date = DATE_SUB('2010-06-17 00:00:00',INTERVAL 4 HOUR);
share|improve this answer
add comment

Your Answer


