Getting today's date from MySQL
Posted: Wed Apr 20, 2005 3:43 am
Hi
I have stored timestamps in a database table in a feild called hit_date and would like to extract only those rows for today!
This returns everything probably because $today = 20050420 which is less than the timestamps.
Do you know what the mysql line should read?
Larry.
I have stored timestamps in a database table in a feild called hit_date and would like to extract only those rows for today!
Code: Select all
$the_date = time();
//calculate today
$today = date("Ymd", $the_date);
#Get hits today
$sql = "select * from hits where aff_id = \"Admin\" and hit_date >= \"$today\" ";
$qry = mysql_query($sql, $conn) or die ("DID NOT hits " .mysql_error());
$num_hits_today = mysql_num_rows($qry);Do you know what the mysql line should read?
Larry.