如何在php中创建时间戳以供将来比较

I want to run a query like this

select * from items where expire > 'time()'

so that i can check which item has the validity. I am trying to set future time like this

$expire=time()+3*86400;///3 days later 

But this is not working.Why ?

using 'time()' in a MySql statement will just insert the string time(), not the actual timestamp.

You should use expire > now() or to use PHP's time function use a statement like:

$sql = "select * from items where expire > '" . time(). "'";

Also, for your PHP statement, it's best to use parenthesis in your equations:

$expire = time() + (3 * 86400);

EDIT:

To show the timestamp / date 3 days from now, your code is correct:

$expire = time() + (3 * 86400);

echo $expire . " - " .  date('d-m-Y H:i:s', $expire);

// OUTPUT: 1420937823 - 11-01-2015 00:57:03 (LONDON TIME)

To use this in a MySql query:

$expire = time() + (3 * 86400);
$sql = "select * from items where expire > $expire";

From OP's latest comment, to do this in AngularJS, either use MomentJS or

var threeDaysFromNow = new Date(new Date().getTime() + 3*24*60*60*1000);
{{threeDaysFromNow.getTime() | date:'medium'}}