Add minutes to current time
date, php
Solution
Your code is redundant. Why format a timestamp as a string, then convert that string back to a timestamp?
Try
$now = time();
$ten_minutes = $now + (10 * 60);
$startDate = date('m-d-Y H:i:s', $now);
$endDate = date('m-d-Y H:i:s', $ten_minutes);
instead.
Problem
I am trying to add minutes to current date but it returns strange results ``` date_default_timezone_set('Asia/Karachi'); $currentDate = date("m-d-Y H:i:s"); $currentDate_timestamp = strtotime($currentDate); $endDate_months = strtotime("+10 minutes", $currentDate_timestamp); $packageEndDate = date("m-d-Y H:i:s", $endDate_months); echo " <br> " . $packageEndDate . " <br> "; echo $currentDate; ``` I am getting Output ``` 01-01-1970 05:50:00 07-19-2013 20:25:23 ``` It should return ``` 07-19-2013 20:35:23 07-19-2013 20:25:23 ``` After this I need to query to database so date format should be same. Database column is of string type.