?
Solved

PHP Download on Modification Timestamp

Posted on 2012-08-17
2
Medium Priority
?
479 Views
Last Modified: 2012-08-17
I use php Curl to download a page periodically. I'd like to only download the file if it's at least a day old. I see filemtime gives the modification time-stamp but I don't get how to convert this.

if (file_exists('test.html')) {
	  if (filemtime > ?? $1day ??) {
               //Nothing to do
          } else {
                 curldownload($url);
} else {
                 curldownload($url);
}

Open in new window

0
Comment
Question by:kjenney
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
kjenney earned 0 total points
ID: 38305465
Figured it out!

if (file_exists('test.html')) {
	 if(filemtime('test.html') <= time()-1440*60)	 {
               //Nothing to do
          } else {
                 curldownload($url);
} else {
                 curldownload($url);
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:kjenney
ID: 38306045
Yeah!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question