Hey, I'm needing help. I'm stuck on something..
I'm wanting to do do this..
if $x is 15 less than $y then
I don't want it to be equal or less than because I've got something that updates every 5 seconds and if it doesn't update within 15 seconds it notifys me.
HELP ME!
Moderator: General Moderators
Re: HELP ME!
So what book are you trying to learn programming from?
Re: HELP ME!
None? I'm just stumped on this part.
I'm wanting to check the "Last modified" time of a file on the server which I know how to,
but if the file hasn't been updated within "X" minutes/seconds whatever, I want it to notify me.
I know PHP, just this part is annoying me.
I'm wanting to check the "Last modified" time of a file on the server which I know how to,
but if the file hasn't been updated within "X" minutes/seconds whatever, I want it to notify me.
I know PHP, just this part is annoying me.
Re: HELP ME!
xDustin wrote:if $x is 15 less than $y then
Code: Select all
if ($x == $y - 15)Re: HELP ME!
Wish it was that easy, but that doesn't work.. That is only if it's exactly 15 less. I'm wanting to do 15 or more/less
I've tried $x == $y > 15 etc but doesn't work.
What I'm exactly wanting to do is...
I've tried $x == $y > 15 etc but doesn't work.
What I'm exactly wanting to do is...
Code: Select all
<?PHP
$last_modified = date("i", filemtime("../images/Temp.jpg")); //Minute point file was last modified
$curr_time = date("i"); //Current Minute for server.
// If $last_modified is 15 OR more minutes behind $curr_time I want it to do what I want.
?>
Re: HELP ME!
1. So it's actually neither the "if $x is 15 less than $y then" nor the "I'm wanting to do 15 or more/less" but
2. Using date("i") is close but not what you want to be doing.value A is no more than value B minus 15
Code: Select all
<?PHP
$last_modified = filemtime("../images/Temp.jpg"); //Time file was last modified
$curr_time = time(); //Current Time for server.
// If $last_modified is 15 OR more minutes behind $curr_time I want it to do what I want.
if ($last_modified <= $curr_time * 15*60) {Re: HELP ME!
That looked promising, but it isn't working.
I've came up with a solution using the date() function, it works.
I've came up with a solution using the date() function, it works.
Code: Select all
<?php
$last_modified = date("i", filemtime("../images/Temp.jpg")); //Minute point file was last modified
$curr_time = date("i"); //Current Minute for server.
$diff = "";
if ($curr_time > $last_modified){
$diff = $curr_time - $last_modified;
}else if($last_modified > $curr_time){
$diff = $last_modified - $curr_time;
}
if ($diff > 5){
echo "Needs updated";
}else{
echo "Already updated";
}
?>