In response to the note whose first line is:
Re note posted by "admin at smitelli dot com"
I believe you have the conversion backwards. You should add an hour to filemtime if the system is in DST and the file is not. Conversely, you should subtract an hour if the file time is DST and the current OS time is not.
Here's a simplified, corrected version:
<?php
function getmodtime($file) { $mtime = filemtime($file);
$diff = date('I')-date('I', $mtime);
return $mtime + $diff*3600;
}
?>
Here's a test:
<?php
$file0 = 'file1.txt';
$file1 = 'file2.txt';
file_put_contents($file0, '');
file_put_contents($file1, '');
$time0=strtotime('Jan 1 2008 10:00'); echo 'Date0 (ST): ' . date(DATE_COOKIE, $time0)."\n";
$time1=strtotime('Aug 1 2008 10:00'); echo 'Date1 (DT): ' . date(DATE_COOKIE, $time1)."\n";
touch($file0, $time0); touch($file1, $time1); $ftime0 = filemtime($file0);
$ftime1 = filemtime($file1);
echo "\nUncorrected: \n";
echo 'File 0: ' . ($ftime0-$time0) ."\n";
echo 'File 1: ' . ($ftime1-$time1) ."\n";
$ftime0 = getmodtime($file0); $ftime1 = getmodtime($file1); echo "\nCorrected: \n";
echo 'File 0: ' . ($ftime0-$time0) ."\n";
echo 'File 1: ' . ($ftime1-$time1) ."\n";
?>
Output:
------------------------------
(when run in summer)
------------------------------
Date0 (ST): Tuesday, 01-Jan-08 10:00:00 EST
Date1 (DT): Friday, 01-Aug-08 10:00:00 EDT
Uncorrected:
File 0: -3600
File 1: 0
Corrected:
File 0: 0
File 1: 0
------------------------------
(when run in winter--dates omitted)
------------------------------
Uncorrected:
File 0: 0
File 1: 3600
Corrected:
File 0: 0
File 1: 0
In response to Re note posted by "admin at smitelli dot com", your version below gives the following output when substituted into my test:
------------------------------
(when run in summer--dates omitted)
------------------------------
Uncorrected:
File 0: -3600
File 1: 0
Corrected:
File 0: -7200
File 1: 0
------------------------------
You can see that the operation is the opposite of what it should be.