0

I have 2 variables being set like this:

      <?php $current = strftime('%m/%d/%g %H:%M:%S')?>
      <?php $target = strftime('%m/%d/%g %H:%M:%S', strtotime($item->getendtime()))?>

Then I have an if statement like this:

      <?php if ($current < $target): ?>
         Do this
      <?php else: ?>
         Do that
      <?php endif; ?>

It works fine until we are in a new year. For example, I have a few items that have an "endtime" in 2012. If the if statement works as it should, it should "DO THAT" but instead it's doing "DO THIS"

4

1 回答 1

2

请改用以下内容(与 unix 时间戳比较):

$current = time();
$target = strtotime($item->getendtime());
于 2013-05-22T03:18:29.783 回答