php - I m not getting proper balanced days from below code:

516
$b='2014-06-01 14:57:15';
echo "Future Date:".$b;
$a=date('Y-m-d H:i:s');
echo "Current Date:".$a;
$c=$b-$a;
echo "Balance:".$c;
/*Its displaying one but want 6 months in answer*/
$d=date('Y-m-d H:i:s')+$d;
echo "New Future Date:".$d;
/*Wants to add with current date so that i get new date*/
653

Answer

Solution:

Try this

 $b='2014-06-01 14:57:15';
    echo "Future Date:".$b;
    $a=date('Y-m-d H:i:s');
    echo "Current Date:".$a;
    $c=strtotime($b)-strtotime($a);
    echo "Balance:".$c;

   d=date('Y-m-d H:i:s' time()+$d);
   echo "New Future Date:".$d;

People are also looking for solutions to the problem: php - How to get the value of a $total before the code calculated?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.