Jump to content

Date(I) problem


Daguse

Recommended Posts

Thanks to unkwntech I found that Date(I); will tell me if the date is daylight saving time or not. 1 if is, 0 if not. However we are in DLS and I am getting a 0. Any Date(I, mktime(any date)); I get 0. even just Echoing Date(I); I get 0.  Is there a reason for this?

 

To give the full pic here, I am trying to make an SQL input with the current date and time. However when DLS comes and goes it changes my input by an hour. Code below.

//date time stamp with local time. 
$DLS = date(I);
if ($DLS > 0) {
$tz = -4;
} else {
$tz = -5;
}
$timezone= $tz;
$time=time();
$gmttime= gmdate("M d Y H:i:s", $time);	
$sqldate=date("Y-m-d H:i:s",strtotime("$timezone hours",strtotime($gmttime)));	

 

Thanks all for helping a basic newbie.

 

 

Link to comment
https://forums.phpfreaks.com/topic/119769-datei-problem/
Share on other sites

sorry, I see now I posted old code.

 

I use date('I'); still does not work.

 

//date time stamp with local time. 
$DLS = date('I');
if ($DLS > 0) {
$tz = -4;
} else {
$tz = -5;
}
$timezone= $tz;
$time=time();
$gmttime= gmdate("M d Y H:i:s", $time);	
$sqldate=date("Y-m-d H:i:s",strtotime("$timezone hours",strtotime($gmttime)));	

Link to comment
https://forums.phpfreaks.com/topic/119769-datei-problem/#findComment-617055
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.