...

View Full Version : Last Modified Date



ginger213
08-07-2012, 11:16 PM
Hi,

I have a php page that imports data from a csv file and I would like it to display the date that the csv file was last modified, but it always shows the date uploaded, and I'm afraid that may not always be accurate.

Is there any way to get the actual modified date, without it changing the last modified date to the date that it was uploaded? The page is supposed to show "current inventory as of last modified date".

Thanks for any tips or suggestions,

ginger

AndrewGSW
08-07-2012, 11:44 PM
Found this:


<?php
// outputs e.g. somefile.csv was last modified: December 29 2002 22:16:23.

$filename = 'somefile.csv';
if (file_exists($filename)) {
echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

I would do this and store the value before importing the data.

AndrewGSW
08-07-2012, 11:46 PM
There was a bug previously with Windows not determining the correct time (don't know if this was fixed subsequently):


<?php
function GetCorrectMTime($filePath)
{

$time = filemtime($filePath);

$isDST = (date('I', $time) == 1);
$systemDST = (date('I') == 1);

$adjustment = 0;

if($isDST == false && $systemDST == true)
$adjustment = 3600;

else if($isDST == true && $systemDST == false)
$adjustment = -3600;

else
$adjustment = 0;

return ($time + $adjustment);
}
?>

ginger213
08-08-2012, 04:32 AM
I would do this and store the value before importing the data.

Hi,

That's what I'm doing, but the last modified date is the date that the file is uploaded to the server rather than the last time the file was changed.

In case I wasn't clear in my first post, the data file is created in Excel and saved as current-inventory.csv. It's to be updated locally and uploaded to the server once a week. The php page imports the data and outputs to an html table. As long as the file is uploaded as soon as it's updated, it's not a problem.

Hope that clarifies.

Thanks,

ginger

Arcticwarrio
08-08-2012, 07:51 AM
you could save the current date / time on the first row and parse it?

ginger213
08-08-2012, 02:12 PM
Thanks for the suggestion. That sounds like it might work.

ginger



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum