luchosoto Posted May 21, 2007 Share Posted May 21, 2007 Hi all!! I've got a bit of a problem and I think you people can help me. I'm using a daylight savings script I found, and I adapted it so that it adjusts the time in my country (Chile). The issue is that the script is set to switch to DST starting on the last Sunday in October until the first Sunday of April. The DST in Chile starts on the second Sunday in October until the second Sunday of March. here's the full code: $calc_adjust = 0; // set time to make change $time_regulr = 3600; // set regular time offset $time_DSTadj = 7200; // set DST time offset $varble_name = "adjust_DST"; // set varialbe name $mnth_server = date("n", time() + $calc_adjust); $dayw_server = date("w", time() + $calc_adjust); $date_server = date("j", time() + $calc_adjust); if ($mnth_server >= 4 && $mnth_server <= 9) { $$varble_name = $time_regulr; // Regular Time } else { if ($mnth_server <= 2 || $mnth_server >= 11) { $$varble_name = $time_DSTadj; // DST } else { if (($mnth_server == 3 && $date_server - $dayw_server <= 0 ) || ($mnth_server == 10 && $date_server - $dayw_server >= 25 )) { $$varble_name = $time_regulr; // Regular Time } else { $$varble_name = $time_DSTadj; // DST } } } echo date("l, F j, Y, g:i A",time() + $$varble_name); How can I fix this line in order to work according to my local DST rules?? if (($mnth_server == 3 && $date_server - $dayw_server <= 0 ) || ($mnth_server == 10 && $date_server - $dayw_server >= 25 )) Any suggestions or solutions are welcome. Thanx in advance!!! Quote Link to comment https://forums.phpfreaks.com/topic/52385-daylight-savings-time-problem/ Share on other sites More sharing options...
chigley Posted May 21, 2007 Share Posted May 21, 2007 Instead of using a dodgy offset, why not let PHP do all the work for you? I'm sure this code will include the DST stuff: <?php ini_set("date.timezone", "Chile/Continental"); // If that doesn't work, use this: date_default_timezone_set("Chile/Continental"); /* Now put the rest of your code here */ ?> Timezones : http://www.php.net/manual/en/timezones.php (Chile/EasterIsland is also available) Quote Link to comment https://forums.phpfreaks.com/topic/52385-daylight-savings-time-problem/#findComment-258503 Share on other sites More sharing options...
luchosoto Posted May 22, 2007 Author Share Posted May 22, 2007 mmhh..I tried but neither of them worked. (perhaps I'm dumb) I can't use date_default_timezone_set b/c the server I'm using has php 4.4.6 installed and I can't do anything about it. How can I fix my messy script then? Thanx!! Quote Link to comment https://forums.phpfreaks.com/topic/52385-daylight-savings-time-problem/#findComment-258661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.