Group and count by month

You need to use the $month keyword in your group. Your new Date().getMonth() call will only happen once, and will try and create a month out of the string “$bookingdatetime”. db.booking.aggregate([ {$group: { _id: {$month: “$bookingdatetime”}, numberofbookings: {$sum: 1} }} ]);

Making a live clock in javascript

Add a span element and update its text content. var span = document.getElementById(‘span’); function time() { var d = new Date(); var s = d.getSeconds(); var m = d.getMinutes(); var h = d.getHours(); span.textContent = (“0” + h).substr(-2) + “:” + (“0” + m).substr(-2) + “:” + (“0″ + s).substr(-2); } setInterval(time, 1000); <span id=”span”></span> … Read more

PHP: Date larger than current date

Try converting them both to timestamps first, and then compare two converted value: $curdate=strtotime(’22-02-2011′); $mydate=strtotime(’10-10-2011′); if($curdate > $mydate) { echo ‘<span class=”status expired”>Expired</span>’; } This converts them to the number of seconds since January 1, 1970, so your comparison should work.