php - OPERATION WITH UNIX DATE -


im making sql this:

select * post date between :date1 , :date2 

date2 going today date php time(); (unix format). need take date2 minus 7days ( 1 week) , date2 minus 1 month.

(this choosen user on form).

the problem can't operation unix dates work.

$date2 = time(); $date1 = $_get['fromdate'];  $query = "select * post           date between :date1 , :date2"; 

html form

 select id=fromdate>     <option value=<?php echo time()-604800>week</option> /select> 

$today = time(); $oneweekago = time() - (60 * 60 * 24 * 7); // 60 seconds, 60 minutes, 24 hours, 7 days $onemonthago = time() - (60 * 60 * 24 * 30); // 60 seconds, 60 minutes, 24 hours, 30 days 

or more exact $onemonthago:

$date = date_create(); // datetime object of today date_modify($date, "-1 month"); // 1 month ago $onemonthago = date_timestamp_get($date); // unix time 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -