Jump to content

Recommended Posts

I'm running PHP 5.6.  I set my web sites time zone with:

date_default_timezone_set('America/Toronto');

This works fine and my site says the proper EST time with the date() command.  I then check if daylight savings time is on with:

echo date('I');

And it says "1" which means it is on.  I need it off.  I need to set my web site to EST with no daylight savings time.  I do not have access to my php.ini.  It has to be done via code.  How can I do that?  Does anyone know?

 

 

Link to comment
https://forums.phpfreaks.com/topic/302105-disable-daylight-savings-time-from-php/
Share on other sites

I think you misunderstand what date('I') is. It does not state whether daylight savings time is "turned on" or not on the server. It returns whether the timestamp passed to the date() function is within the the dates for daylight savings (When no timestamp is passed it uses the current timestamp). This year, daylight savings in US/Canada goes from March 13, 2016 to Nov 6, 2016. Any timestamp passed to date() within those two dates will return true for the "I" parameter for those timezones where it applies. You cannot "turn that off" any more than you can turn off Christmas from being on Dec. 25th.

 

What are you, specifically, trying to accomplish and/or what problem are you experiencing that the daylight savings is causing?

Edited by Psycho

Sounds like OP is using "EST" as a layman's term. So

This works fine and my site says the proper EDT time with the date() command.

I need it off.  I need to set my web site to the same time that EST would show but all year long.

Sounds like OP is using "EST" as a layman's term. So

 

That's my belief as well. EST and EDT are both used to show the current, "true" time for people in that timezone. The S vs D is used to identify if that time is during the daylight savings period or not. It really doesn't have much use to people in that timezone because they don't have to translate the time. It is necessary when communicating time to other people in different timezones so they can convert correctly. Many regions/countries do not use DST, so if a meeting is scheduled for 5:00PM, the EST vs EDT is very important to participants in India (for example) which does not use daylight savings time. For them, the meeting could be at 2:30AM (if 5PM EDT) or 3:30AM (if 5PM EST).

 

If the audience is all in the same timezone (or at least North America) it is acceptable to leave out that identifier and just use 5:00 ET.

Yes, I'm saying EST simple as in new york time.  Now when DST comes around on Nov 6, 2016 I do not want the time turned back 1 hour and therefore the time reported by the PHP date() command on this specific web site to stay the same.  possible?

You are in daylight savings time right now, so your request doesn't make much sense in terms of how the real world works.

 

But if you want to invent your own personal timezone, that's of course technically possible:

<?php

date_default_timezone_set('Etc/GMT+4');

var_dump(date('H:i:s'));

I need it off.  I need to set my web site to EST with no daylight savings time.

Now when DST comes around on Nov 6, 2016 I do not want the time turned back 1 hour

Which is it? Daylight savings or no daylight savings?

It makes no sense to use a time that nobody else is using, unless this is for Indiana, Arizona, Saskatchewan(?) or parts of the Caribbean.

My special powers tell me that OP is in the regular ol' EST/EDT region in Canada, and where America/Toronto is the correct timezone identifier.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.