How to compare a system date with the date from MySQL database in php -


i want compare system date date mysql database , comparison should if system date has diffrence of 10 days date table's date.

for e.g. sytem date: 2013-7-31 , table's date 2013-8-10 should echo msg "10 days left renewal."

i know how add days date in php have no idea of how should compare these two.

$mydt = date("y-m-d"); $alertday = date('y-m-d', strtotime($mydt. " + 10 days")); 

just convert db table time normal unix timestamp subtract , divide number seconds in day

$now = time(); $dbtime = strtotime($tabledate);  $daysleft = ($now-$dbtime) / ( 60*60*24); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -