Hi guys,
What the expression do below?
Explain in plain english.
if ( ( strtotime(date('Y-m-d')) > strtotime($row['date_trial'])+60*60*24*4 ) )
Okay here is my understanding below,
If current time is greater than 4 days?
or
If current time is less than 4 days?
Am I right?
“If it has been more than 4 days since date_trial”
Or more directly translated:
If the current time is greater than (after, because were measuring in seconds-since-epoch) the timestamp of the row’s date_trial field plus 4 days
Hi solidcodes,
You were right the first time… the condition is true if the current date is more than 4 days after date_trial
.
Edit: Beaten to it 
@StarLion ;
@fretburner ;
Guys thank you very much.
But how about I want the condition like this.
3 days before the trial will end?
What is the right expression for this?
Thanks in advance.
As StarLion pointed out, you’re using timestamps which are measured in seconds. As you can see here, the number of seconds in four days is being calculated:
60*60*24*4
so you just need to change the last number to the number of days you want.
@fretburner ;
So this is what I come up so far.
“3 days before the end of trial date.”
if ( ( strtotime(date('Y-m-d')) > strtotime($row['date_trial'])-60*60*24*3 ) )
Is this correct?
Thanks in advance.
What you’re doing at the moment is checking if the current date is later than three days before the end of trial. Are you wanting to check if the current date is exactly three days before the end of trial date (like to send a reminder, or something)?
@fretburner ;
Yes exactly this is what I want below,
Are you wanting to check if the current date is exactly three days before the end of trial date (like to send a reminder, or something)?
Thanks in advance fret.
Something like this should do the trick:
$today = strtotime(date('Y-m-d');
$trial_end = strtotime($row['date_trial']);
$day = 86400;
if ( $today > ($trial_end - $day * 3) && $today < ($trial_end - $day * 2) ) {
}
@fretburner ;
What is this expression do below?
Let say $row[‘date_trial’] = ‘2010-12-17’;
strtotime($row['date_trial'])+60*60*24*3
According to my understanding the expression above, beginning date_trial plus 3 days.
Am I correct?
Thanks in advance.