I cannot figure out why but every time I save an entry, I lose 1 hour on my date custom fields.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
September 29, 2010 4:57pm
Subscribe [3]#1 / Sep 29, 2010 4:57pm
I cannot figure out why but every time I save an entry, I lose 1 hour on my date custom fields.
#2 / Sep 29, 2010 6:16pm
I checked and both my PHP and MYSQL have the same timezone of PDT
#3 / Sep 29, 2010 8:44pm
OK so it appears that this only effects dates after DST ends and before it begin again. I have a 1.6 EE install on the same server and it works just fine. It appear to only effect 2.1 (any build - but I am running the newest)
#4 / Sep 29, 2010 10:14pm
So I have updated the system/expresionengine/fieldtypes/ft.date.php file so the save function looks like this
function save($data)
{
if ($data != 0 && date("I",$data) == 0){
$data = mktime(date("H",$data)+1,date("i",$data),date("s",$data),date("n",$data),date("j",$data),date("Y",$data));
}
return $data;
}It appears to be working.
Edit… code was bad :(
#5 / Sep 30, 2010 10:51am
I found this solved the same issue I was facing - but I was wondering what it actually does to the date? When EE is updated will it effect anything?
#6 / Sep 30, 2010 10:55am
Well this is a bad way to fix it but it fixes it and I hope that EE releases a real fix before DST turns off. I will keep this post updated as I continue to test this.
#7 / Sep 30, 2010 5:51pm
Thanks for your help rjsteck. Unfortunately this fix breaks when the expiration date or comment expiration date is left black - the date is automatically filled with a date starting in 1970. Is it possible to detect if a date has been added, if not it is skipped?
Thanks.
#8 / Oct 01, 2010 1:43pm
Thanks for your help rjsteck. Unfortunately this fix breaks when the expiration date or comment expiration date is left black - the date is automatically filled with a date starting in 1970. Is it possible to detect if a date has been added, if not it is skipped?
Thanks.
Sorry, this fixes it
function save($data)
{
if ($data != 0 && date("I",$data) == 0){
$data = mktime(date("H",$data)+1,date("i",$data),date("s",$data),date("n",$data),date("j",$data),date("Y",$data));
}
return $data;
}I want you to know this is not a “fix” this is a hack until I get time to fix it correctly. I will try to do it over the weekend but this was discovered on a LIVE site and we had to fix it ASAP and since I am not super familiar with EE code, I was not able to find the correct place to make the change.
More to come…
#9 / Oct 01, 2010 1:46pm
Thanks rjsteck, appreciate your help. We’re coming up to launching a site very soon, so may have to implement this hack - hoping EE fixes this themselves soon!
#10 / Oct 01, 2010 1:52pm
Thanks rjsteck, appreciate your help. We’re coming up to launching a site very soon, so may have to implement this hack - hoping EE fixes this themselves soon!
I know your pain. This is on a live site for us and they sent me an email “the expiration times are wrong” at the same time I got your post which was causing a bunch of pages to become 404 pages :( Like I said, I will continue to work on this until we have an “official” fix.
#11 / Oct 02, 2010 6:08pm
I suggest we close this thread (or delete it) and point all traffic to http://ellislab.com/forums/viewthread/168956/ as both threads cover the same issue.
#12 / Oct 04, 2010 2:55am
Closing thread as requested as issues are covered here