Jump to content

Recommended Posts

I have made me a script to generate a picture from many different pictures, also with text on.

This script does make two different pictures, but that's not importaint.

What i had in mind was to check that age of the generated file before it run the script that i have now.

By using the filemtime, i get the last modification time... i managed that. But it is in an exact time.
How would i have to make the codes to do this:
- mod-time - 1 hour.
In other words i want to do this:
- if mod-time is older then 1 hour, continiue with script, or else, do to ../gallery/photos.....

If i get this to work i'll splitt it later, because this two different pictures had different rate of refreshing.

Thanks for the time to read this.


Link to comment
https://forums.phpfreaks.com/topic/10759-checking-age-of-file/
Share on other sites

[!--quoteo(post=378372:date=May 30 2006, 03:59 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 30 2006, 03:59 PM) [snapback]378372[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This function might help:

filemtime -- Gets file modification time
[a href=\"http://www.php.net/filemtime\" target=\"_blank\"]http://www.php.net/filemtime[/a]
[/quote]

Yeah, i have been there and made it to work, but how to do the rest... then i got a problem.
I probably could set a time using this timesystem, but f.ex take - 1 hour... how would that be?
And also in case i get it to work.
Will i place the if with all the rest of my code in one of the cases?

Thanks for the reply
Link to comment
https://forums.phpfreaks.com/topic/10759-checking-age-of-file/#findComment-40249
Share on other sites

Erm... To set the modification/creation time you can use touch()
[a href=\"http://www.php.net/touch\" target=\"_blank\"]http://www.php.net/touch[/a]

They use UNIX timestamps, so if you want to take an hour just use ($date - 3600) or whatever.

I don't know what "if" you are talking about...
Link to comment
https://forums.phpfreaks.com/topic/10759-checking-age-of-file/#findComment-40265
Share on other sites

[!--quoteo(post=378400:date=May 30 2006, 05:28 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 30 2006, 05:28 PM) [snapback]378400[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I don't know what "if" you are talking about...
[/quote]
I'll try again...

the situateion is like this....
I got a script, it generate 2 pictures. But it takes maybe 1.5 sec to run. To make the script be faaster i was thinking that if the files that is generated is newer then 1 hour, then don't run the generatting part.
So i win 1.5 sec to pass that part.

So my "if" would be like... [i]if, file.jpg is older then 1 hour, run script, if not, [!--coloro:#009900--][span style=\"color:#009900\"][!--/coloro--]header("Location: ../gallery/index.php?twg_noborder=true")[!--colorc--][/span][!--/colorc--][/i]

Hope this clear out a little (i know the "if" i made here have nothing to do with programing, it's just to explain) The Green text is the final part of my script and shold be like that... (bouth cases should end with that)

thanks again for the time
Link to comment
https://forums.phpfreaks.com/topic/10759-checking-age-of-file/#findComment-40338
Share on other sites


Thanks... it helped alot.
I also got one script like this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
$age = filemtime("../gallery/pictures/Photos/Weather/1overlay2.jpg") + 3600;
if (time() < $age) {
print ("Fresh");
}
else{
print("Old");
}[/quote]

This one is the one i'll be using... pretty much like this i guess.

Link to comment
https://forums.phpfreaks.com/topic/10759-checking-age-of-file/#findComment-40637
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.