title: PHP: time calculation using datetime()
body: <p>I'm making a time calculator that adds or subtracts days, hours and minutes from the current time in UTC timezone, or a user-defined date stored in a MySQL database. My current code works, but I haven't been able to figure out how to adjust the time format.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$days = "+2 days";
  $hours = "+1 hours";
  $minutes = "+5 minutes";
  
  $time = new DateTime(); // assumes current time
  $time-&gt;setTimezone(new DateTimeZone('Europe/London'));
  $time-&gt;modify("$days, $hours, $minutes");
  echo $time-&gt;format("g:i A l jS F"); // outputs time
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <p><code>11:48 PM Sunday 4th January</code></p>
  
  <p>What would be the appropriate formatting to use, to get the interpreter to output the date as "11:48 PM on Sunday the 4th January"? Adding characters like "N" and "J" will mess up <em>(and/or scramble)</em> the date, even when escaped with one or more "\". Strangely enough, this doesn't happen with half the alphabet...</p>
  
  <p>I've been searching the interwebs but haven't found an answer that explains this phenomenon.</p>
  
  <p>Appreciate the help!</p>