note 82179 added to function.filemtime

From: Date: Sun, 30 Mar 2008 16:56:55 +0000
Subject: note 82179 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-137762@lists.php.net to get a copy of this message
I created an application which stores files as blobs in a database, and retrieves them upon user request (into a webDAV-enabled area). The files are touched so that they have the correct timestamp information after being retrieved. After the user is done making any alterations, a script runs that checks for changes in the files (including timestamps). It appears that working with timestamps on files under Windows systems (XP/Server 2003) is a problem, because the timestamp on files, for example, will toggle between 1pm and 2pm depending on the age of the file and if it is DST or not. Try this experiment: $timestamp_str = "2005.02.06 14:45:33"; $timestamp_pieces=split('[. :]',$timestamp_str); $timestamp=mktime($timestamp_pieces[3], $timestamp_pieces[4], $timestamp_pieces[5], $timestamp_pieces[1], $timestamp_pieces[2], $timestamp_pieces[0]); touch("c:\\timestamp_test.txt",$timestamp); The file timestamp_test.txt shows up in the operating system as having a modification date of "Sunday, February 06, 2005, 2:45:33 PM" - which is the desired result. But now look at the results of filemtime (only when in DST - it will report the correct timestamp during standard time): $compare_timestamp=filemtime("c:\\timestamp_test.txt"); $compare_timestamp_str = date("Y.m.d H:i:s",$compare_timestamp); echo "$timestamp ($timestamp_str) is the original timestamp.<br />\n"; echo "$compare_timestamp ($compare_timestamp_str) is the timestamp on the file.<br />\n"; The output looks like this: 1107726333 (2005.02.06 14:45:33) is the original timestamp. 1107722733 (2005.02.06 13:45:33) is the timestamp on the file. The filemtime function reports a timestamp different from what the OS reports. You'll likely need to code around this issue if you are attempting something similar - because this is not a PHP bug but a "Microsoft feature". ---- Server IP: 69.147.83.197 Probable Submitter: 216.150.207.36 ---- Manual Page -- http://www.php.net/manual/en/function.filemtime.php Edit -- https://master.php.net/note/edit/82179 Del: integrated -- https://master.php.net/note/delete/82179/integrated Del: useless -- https://master.php.net/note/delete/82179/useless Del: bad code -- https://master.php.net/note/delete/82179/bad+code Del: spam -- https://master.php.net/note/delete/82179/spam Del: non-english -- https://master.php.net/note/delete/82179/non-english Del: in docs -- https://master.php.net/note/delete/82179/in+docs Del: other reasons-- https://master.php.net/note/delete/82179 Reject -- https://master.php.net/note/reject/82179 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137762) next »