Avatar of steinonline
steinonline
 asked on

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

Avatar of undefined
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.
SOLUTION
btdownloads7

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

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
ASKER CERTIFIED SOLUTION
steinonline

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Dave Baldwin

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
btdownloads7

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.