title: Call to undefined method DateTime::add() - PHP Version 5.4.6
body: <p>I've got the following function which I had help building at <a href="https://stackoverflow.com/questions/12400154/compare-day-with-day-and-find-next-date-of-day-in-php/12400494">this topic</a></p>
  
  <pre><code>function nextDelivery($day,$o_date,$oc) {
      $day_names = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
      $day_num = array_search($day, $day_names);
      $o_date = new DateTime($o_date);
      $o_day_num = $o_date-&gt;format('w');
      $day_diff = ($day_num - $o_day_num) % 7;
      if($day_diff&lt;0){$day_diff=7+$day_diff;}elseif($day_diff==0){$day_diff=7;}
      if($oc==2){$day_diff+7;}
      $order_day = clone $o_date;
      $order_day-&gt;add(new DateInterval("P".$day_diff."D"));
      return $order_day-&gt;format('Y-m-d H:i:s');
  }
  </code></pre>
  
  <p>Now I've just changed my time stamp to Pacific/Auckland, as my host was America/Denver. This has changed everything except for files run using Cron Jobs, they are still outputting the old timestamp. Now if I run this function on a page in my site it woks fine, but if a cron job file, using the exact same function runs I get the following error</p>
  
  <p><code>PHP Fatal error:  Call to undefined method DateTime::add() in ***** on line 156</code></p>
  
  <p>which is <code>$order_day-&gt;add(new DateInterval("P".$day_diff."D"));</code></p>
  
  <p>This is my info <a href="http://www.dpdesignz.co.nz/homefresh/lib/php_info.php" rel="nofollow noreferrer">http://www.dpdesignz.co.nz/homefresh/lib/php_info.php</a></p>
  
  <p>Does anyone have any ideas as to why this may be happening?</p>