file modified time on local machine does not match file modified time on remote server returned with .php function
Hello experts, I am having a bit of trouble comparing local file dates and times to those on a unix/apache server. I am working on an incremental backup procedure that only uploads files that are newer on the local machine. Problem is that once uploaded the datetime information in the file is not being returned by php. Server filetime gets returned. Is there any way to get the .filetime from the file as it was uploaded?
Adobe DreamweaverPHP
Last Comment
steinonline
8/22/2022 - Mon
Dave Baldwin
If you are in a different timezone, I don't think the times will ever match. When PHP reads the file info, it is reading it on the server without knowing what timezone it will be viewed in. You can set the timezone you're using on the server. http://us3.php.net/manual/en/function.date-timezone-set.php I think you'll have to convert the time you read.
What btdownloads7 said: you really don't want to depend the the filesystem timestamp.
One strategy you might consider: Make an md5() digest of each file. When it's time to run the backups, make a new md5() digest of the file and compare to the old md5() digest. If these match, the files have not changed. If they do not match, you need a new backup. http://php.net/manual/en/function.md5.php
You realize that if you send local time to a remote server and other people in other time zones are doing that also, you will not be able to tell what order by time the files were uploaded.
You said you're trying to use this for backup. To do that properly, you need to keep a database that tracks all the information about each file, like the timestamp that can be standardized using a script that will be used to upload the files. If you're only backing up one client, the there is only minimal use for a tracking DB. But if you have multiple clients trying to upload data, especially if they're synchronizing to the same set of files, then you absolutely have to keep a tracking DB.
steinonline
ASKER
Each individual client has their own autonomous set of data. The file date times are only used by them so in that regard time zone makes no difference whatsoever as the times will be encoded from their own time zone to begin with. I appreciate your help and concern but such a solution may actually over complicate the situation.
steinonline
ASKER
My reason for selecting my own solution is simple... It works with the least amount of overhead, I have considered the experts comments carefully and I will award majority of the points to btdownloads7 because I appreciate the help, I built a crude model from his suggestion, however I feel that my solution is unique and worth doing. I do have some expertise myself.