takn25 Posted April 10, 2011 Share Posted April 10, 2011 Hi, I am trying two compare to dates but have not been successful. A row is filled in Mysql database called htime with $check=mktime(17,0,0,04,10,2011); My first question is that in the mktime function I have entered 17 which is hours. I would like to know if thats like the 17th hour of the given day or thats not how it works? My second question is it a valid query to use <= or >= or < in a mysql query for example. $query="SELECT * FROM hdb WHERE htime <='".time()."'"; Thirdly I want to know if a row is filled with mktime(17,0,0,04,10,2011); for example How can I only extract the day from the database based on the time has passed? This is because my own query doesnt seem to be working which is the query above I have no errors but the results dont seem to be right. Any help is much appreciated thanks. Link to comment https://forums.phpfreaks.com/topic/233259-a-little-help-with-queries-and-dates/ Share on other sites More sharing options...
litebearer Posted April 10, 2011 Share Posted April 10, 2011 1) mktime creates a time stamp 2) Yes, 17 would mean 5PM 3) Yes, you can use >, <, = etc http://php.net/manual/en/function.mktime.php got more on mktime Link to comment https://forums.phpfreaks.com/topic/233259-a-little-help-with-queries-and-dates/#findComment-1199614 Share on other sites More sharing options...
Pikachu2000 Posted April 10, 2011 Share Posted April 10, 2011 You should really do yourself a favor and store the values in MySQL's native YYYY-MM-DD HH:MM:SS format in a DATETIME field. Then you can use the date/time functions available in MySQL to perform comparisons and calculations Link to comment https://forums.phpfreaks.com/topic/233259-a-little-help-with-queries-and-dates/#findComment-1199762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.