Jump to content

Comparing Dates with mktime()


jawaidpk

Recommended Posts

Hi Friends,

 

I have a task in which I have to fetch a row from database table created on specified date, the problem is that the  date stored in db table is actually the integer value of mktime(), and this value will be different for every min in a single day, so how can I write the query which will fetch all the rows created on a given DATE. Lets say if 5 records are created at 01-11-2008 at different times then there will be 5 different values in database table but I need all of them to be fetched with one query. so how can I write the WHERE clause in this situation.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/130963-comparing-dates-with-mktime/
Share on other sites

If I understand it correctly, you could do it like this:

 

$start_date = mktime(0, 0, 0, 1, 11, 2008);
$end_date = $start_date + (60*60*24); // Add one day

$sql = "SELECT * FROM your_table WHERE the_date >= $start_date AND the_date <= $end_date";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.