I am getting time with function date('Y-m-d h:i:s'); but I need to subtract couple hours and minutes from current time, how I can do that ? Thank You
It cannot be done directly but there is another way.!! Convert your date to unix timestamp using mktime(). It will only give a numerical value and substract it from current timestamp and it will give you the second difference.
$currtime = date('Y-m-d h:i:s'); $five_days_ago = strtotime($currtime." - 5 days"); // this is in timestamp format $five_days_ago_date = date("Y-m-d h:i:s", $five_days_ago); // converted back to your date format // another example $one_month_later = strtotime($currtime." + 1 month"); $one_month_later_date = date("Y-m-d h:i:s", $one_month_later); PHP: In short, $five_days_ago_timestamp = strtotime(date('Y-m-d h:i:s')." - 5 days"); PHP: