Forum Moderators: coopster
I have some records in my table that I need to extract if they are equal or greated than the current date. The date fields are in format YYYY-MM-DD. Could someone please provide some details on how to do this in php, I think I have a rough idea.
set date variable to current date
select all records from database where database date is >= current date
Thanks
$query = "select * from table_name where database_date >= '$current_date' ";
BTW, I always use int(10) to store the dates and I store the date value in UNIX timestamp returned by the PHP time() function. Im my case, the code above will looks like:
//we need the date in YYYY-MM-DD format
$current_date = mktime(0,0,0,date("m"),date("d"),date("Y");
$query = "select * from table_name where database_date >= '$current_date' ";
I think the MySQL server works faster if only some mumbers must be checked, instead of checking valid dates.
I am trying to convert the date coming from the database ($date) to a user friendly format (E.g "19th May, 2004").
I am using the following code :
<?
$new_date = mktime(0,0,0,$date("m"),$date("d"),$date("Y");
Print "$new_date";
?>
Can someone point me in the right direction please :)