Jump to content

Php Date Help


hosker

Recommended Posts

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

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

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.