title: PHP get UTC/GMT time, round to nearest minute, and format to yyyyMMddHHmm
body: <p>I'm generating a UTC/GMT date with PHP that needs to be in the format <code>yyyyMMddHHmm</code> and needs to be rounded to the nearest minute.</p>
  <p>For example, <code>January 3rd, 2020 13:28:56</code> needs to be <code>202001031329</code> and it needs to be rounded to the nearest minute. (30 seconds or greater rounds up, otherwise round down)</p>
  <p>For example:</p>
  <pre><code>&lt;?php 
  /*
  Start with the UTC/GMT time -- January 3rd, 2020 13:28:56
  Round to the nearest minute -- January 3rd, 2020 13:29:00
  Convert to format yyyyMMddHHmm -- 202001031329
  */
  
      $date = gmdate(&quot;YmdHi&quot;, time());
      // Need to round to the nearest minute (30 seconds or greater rounds up, otherwise round down)
      echo $date;
  ?&gt;
  </code></pre>
  <p>So far I've figured out how to get the current date with the <code>gmdate()</code> and put it in the right format. However, I'm not sure how to round to the nearest minute.</p>