I wanted to add 30 days in my current order_date which is retrieved from db automatically and display the date which is 30 days ahead.But the result which i am getting is something like this 14437368002015-11-01 when the order_date was 2015-10-01.1443736800 gets Added before the date .Please help!
while($row = mysqli_fetch_array($query)){
echo '<tr>'.
'<td align="center">'.$row['order_no'].'</td>'.
'<td align="center">'.$row['order_date'].'</td>'.
'<td align="center">'.$row['store_used'].'</td>'.
'<td align="center">'.$row['status'].'</td>'.
'<td align="center">'.'Rs.'.$row['cashback'].'</td>'.
'<td align="center">'.$date = strtotime($row['order_date']);
$date = strtotime("+30 day", $date);
echo date('Y-m-d', $date);'</td>'.
'</tr>';
}
echo '</tbody></table></form>'."
";
mysqli_close($dbc2);
?>
Results:
Order ID Order Date Store Used Status Cashback Est.Cashback.Date
134 2015-10-02 Flipkart To be Checked Rs. 14437368002015-11-01
It seems you have concatenation issue simply you can also directly use date
function like as
'<td align="center">'.date('Y-m-d',strtotime("{$row['order_date']} +30 days")).'</td>'.
It seems from your code that your code is echoing date twice
'<td align="center">'.$date = strtotime($row['order_date']);//starting of td
and
echo date('Y-m-d', $date);'</td>'. //ending of td
This should work for you, you are not converting the date after strtotime()
.So convert it with date()
$date = strtotime("2015-10-01");
$date = date("Y-m-d",strtotime("+30 day", $date));
echo $date;// outputs 2015-10-31