I’m pretty stumped here. I’m adding an additional index and setting it to true if a condition is met. The condition is based of the time and 30 minutes ahead of time.
$date = new DateTime();
$date->setTimestamp(time());
$row['editable'] = false;
if ((strtotime($row['date']) + 1800 > $date->getTimestamp())) {
$row['editable'] = true;
}
What I’m attempting to do is add 1800 seconds(30 minutes) of the row[‘date’] in order to run it against the current time stamp. But this condition is never met.
Am I misunderstanding how unix time stamp works? I’ve looked all over and found that I seem to be doing it correctly.
I did do the span of 24 hours:
ie. 24 * 60 * 60
and it worked correctly, so I’m not sure where I went wrong. I’m looking for 30 minutes only, which is 1800.
…and it still isn’t adjusting correctly. First time, I’ve ever experienced this.
EDIT:
I added the time zone abbreviation and it seems it’s running on UTC + 4 so I adjusted it (-14400) and it seems to be working correctly now. I find it weird that it won’t adjust the time difference when setting the timezone object.
It seems that it works correctly if I hard code the time into it like you did. But it doesn’t seem to work if it’s dynamically coming from the database.
EDIT:
I ran this:
1278870381 time(): 1278885224
the difference between the two at the time is 14, 843 seconds. About 4 hours of a difference. hmm weird.