Hi there,
I was hoping for a little help please...
I want to calcuate the number of days between the current date and a date found in a field in my database table.
So pefectly illustrated is with this Mysql code:
SELECT DATEDIFF (CURDATE(), SowDate) AS intval FROM `vegeschedule`
Using the above code works a charm in phpmyadmin but i realise the tricky bit is to do it with php.
So far i have found a basic coutdown script that counts down from the current date to a manually inputted date....I need to to use the current date and a date in a field in my table.
Heres the coutdown script:
<?php // Define date format
$dateFormat = "Y-m-d H:i:s";
$targetdateDisplay = date($dateFormat,$targetdate);
$actualdateDisplay = date($dateFormat,$actualdate);
$result =mysql_query($sql);
$row = mysql_fetch_array($result);
// Define your target date here
$targetYear = $row['year'];
$targetMonth = $row['month'];
$targetDay = $row['days'];
$targetHour = 12;
$targetMinute = 00;
$targetSecond = 00;
// End target date definition
$targetdate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
$actualdate = time();
$secondsDiff = $targetdate - $actualdate;
$remainingDay = floor($secondsDiff/60/60/24);
$remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
$remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
$remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
// Define date format
$dateFormat = "Y-m-d H:i:s";
$targetdateDisplay = date($dateFormat,$targetdate);
$actualdateDisplay = date($dateFormat,$actualdate);
?>
<br />
<font size="+1" color="#FF0000">Expires In: <?php echo "$remainingDay days";?> </font> </p>
Please NOTE the target date hasn't been set yet.....
I tried to add my php query to get the date value from the database (below) but just dont know what the hell to do now....
mysql_select_db($database_connect, $connect);
$sql = "SELECT ''SowDate' FROM vegeschedule";
If anybody could please help me that would be great...I have spent nearly ALL day and night yesterday trying to get working....
Thank You 🙂