hosker Posted December 13, 2012 Share Posted December 13, 2012 I have searched the forum, but I did not finda post that would help me with my issue. I have a cron job that I am going to run every monday, however, I do not want to type out all of the dates into an if else statement, but would rather write it in a loop. I want to pull the date from the database table, which is always going to be a Thursday( and an ocassional Wednesday), and check to see if the Monday prior is todays date, and if it is, I want to pull the file tournament_id from my database and insert it into a variable. How can this be done? The date is in the following format: YYYY-MM-DD. Thanks in advance for your help. Link to comment https://forums.phpfreaks.com/topic/271941-php-date-help/ Share on other sites More sharing options...
Muddy_Funster Posted December 13, 2012 Share Posted December 13, 2012 do it in the query using a DATEDIFF() in the where clause Link to comment https://forums.phpfreaks.com/topic/271941-php-date-help/#findComment-1399103 Share on other sites More sharing options...
hosker Posted December 15, 2012 Author Share Posted December 15, 2012 I am using strtotim() which I can get to work outside of my SQL query. How would I mkae this SQL statement work" $today = strtotime(date('2013-01-07')); $sql = "SELECT * FROM tournaments_2013 WHERE (strtotime('Last Monday', start_date) = $today)"; $result = mysql_query($sql); print_r($result); exit; echo "<table><tr><th>Tournament</th></tr>"; while($row = mysql_fetch_array($result)) { echo "<tr><td>" . $row['tournament_id'] . "</td></tr>"; } echo "</table>"; Link to comment https://forums.phpfreaks.com/topic/271941-php-date-help/#findComment-1399496 Share on other sites More sharing options...
Christian F. Posted December 15, 2012 Share Posted December 15, 2012 strtotime () is a PHP function, not an MySQL function. For MySQL you'll need to use MySQL's datetime functions. Link to comment https://forums.phpfreaks.com/topic/271941-php-date-help/#findComment-1399507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.