Skip to content

Instantly share code, notes, and snippets.

@1stevengrant
Created October 28, 2012 17:21
Show Gist options
  • Select an option

  • Save 1stevengrant/3969207 to your computer and use it in GitHub Desktop.

Select an option

Save 1stevengrant/3969207 to your computer and use it in GitHub Desktop.
Fixes the daylight savings issue with EE
var $dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/New_york'));
$dateTime->setTimestamp(time());
$isDst = (bool)$dateTime->format('I') ? "y" : "n";
$conf['daylight_savings'] = $isDst;
@cleverlever
Copy link
Copy Markdown

And you might have to do something like this for your old entries when going from UM6 (CDT) to UM5 (CST) and using "fixed" dates (field_id is 394).

update exp_channel_data SET field_dt_394 = 'UM5';

Or switch everything to localized using (field_id is 394).

update exp_channel_data SET field_dt_394 = '';

@rsanchez
Copy link
Copy Markdown

PHP 5.2 version:

$dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/Chicago'));
$date = getdate();
$dateTime->setDate($date['year'], $date['mon'], $date['mday']);
$dateTime->setTime($date['hours'], $date['minutes'], $date['seconds']);
$conf['daylight_savings'] = $dateTime->format('I') ? 'y' : 'n';

@benjamin-smith
Copy link
Copy Markdown

America/New_york should be America/New_York, no? http://www.php.net/manual/en/timezones.america.php

@jayeshjain24
Copy link
Copy Markdown

My website is having a countdown from 23july to current time.I am from india and my timing lag 5.30 hours.The problem is the site is also for pakistan,srilanka,bangladesh.So i need to have respective timezone using php.Any idea?Currently the countdown get deprecated by one day at 5.30 in morning instead of midnight

http://www.tensports.com/event/other/commonwealth-games-2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment