I am struggeling with some basic date-formatting and echo the right number for "Days Left". This is the code:
date_default_timezone_set('Europe/Oslo');
$dateNow = date('d/m/Y', time());
$dateStart = date('d/m/Y', strtotime('01/08/2014'));
$dateFinished = date('d-m-Y', $dateStart + strtotime("+62 days"));
$daysLeft = intval($dateFinished-$dateNow);
echo($dateNow. "<br>");
echo($dateStart. "<br>");
echo($daysLeft. "<br>");
This is the echo: 07/07/2014 01/08/2014 -6
It seems like dateStart is interped as a wrong format. I have tried with both - and /, but nothing better.
What have i done wrong? Just the math or is it the logic?
var_dump($dateStart + strtotime("+62 days"));--- never assume, always check.