I want to subtract two dates which will give me the difference of 15 days only and then send an automatic email without user interaction? How is that possible?
Here is my PHP Code
<?php
$user = 'root';
$pass = '';
$con = 'pharmacy';
$con = new mysqli('127.0.0.1', $user, $pass, $con);
if(!$con)
{
echo 'Unable to Connect with Server';
}
if (!mysqli_select_db($con,'pharmacy'))
{
echo 'Database is Not Selected';
}
//select database
mysqli_select_db($con,'pharmacy');
//Expiry Date which is stored in Datebase
//Convert String into Date Format
$sql_unique=$con->query("SELECT exp_dt FROM scandrug");
$expiry = strtotime($sql_unique);
$newformat = date('d-m-Y',$expiry);
$day= date('d',$newformat); //Day of the month
$month= date('m',$newformat); //Month of the year
$year= date('Y',$newformat); //Year
//echo $newformat;
//Obtain current Date
$current_dt = new DateTime();
$current_dt= date('d-m-Y');
$dayy= date('d',$current_dt); //Day of the month
$monthh= date('m',$current_dt); //Month of the year
$yearr= date('Y',$current_dt); //Year
//echo $current_dt;
do{
if($day-$dayy==15 || $day-$dayy==-15 && $month-$monthh==01 || $month-$monthh==00 && $year-$yearr==0000)
{
}
else
{
//nothing will happen
}
}while(1);
?>