title: Round time to the nearest 30 min using moment.js #javascript
body: <p>I would like to round to the nearest 30 mins with moment.js, Below is my current code which doesn't work at the moment. Maybe i don't have the right moment.js syntax. When I use the normal Date object from javascript it works fine.</p>
  
  <pre><code>&lt;script type="text/javascript" src="moment-with-locales.js"&gt;
  
  
  var jetzt = moment().format('lll');
  jetzt.seconds(0);
  jetzt.milliseconds(0);
  var minuten = jetzt.minutes();
  var minutenToAdd = 0;
  if (minuten &gt;= 0 &amp;&amp; minuten &lt;= 29)
  {
      minutenToAdd = 30 - minuten;
  }
  else if (minuten &gt;= 31 &amp;&amp; minuten &lt;= 59)
  {
      minutenToAdd = 60 - minuten;
  }
  var MIN_IN_MS = 60000;
  var HALF_HOUR_IN_MS = 3600000;
  
  minutenToAdd = minutenToAdd * MIN_IN_MS;
  var Datum = moment(jetzt.moment() + minutenToAdd).format('lll');
  alert(Datum);
  
  
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>thx for help :)</p>