PHP Function – Calculating Days In A Month
All developers keep a tool box of useful functions and classes that they pick up or write along the way and this PHP came to me while I was writing an event calendar page for a customer.
I should mention that PHP does offer a cal_days_in_month function for PHP builds of PHP 4.0.7 and higher, but I prefer using the below function because it is guaranteed to work on all PHP version because it is based solely on logic.
function get_days_in_month($month, $year)
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
One line of logic provides the number of days in a month, taking into account leap years, and all on one line.
I was inspired when I first saw Addy Osmani's original ShineTime blog post. The hover sheen effect is simple but awesome. When I started my blog redesign, I really wanted to use a sheen effect with my logo. Using two HTML elements and...
For quite a long time now websites with the so called "parallax" effect have been really popular.
In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...
It's often interesting to think about where on a given element, whether it be the page, an image, or a static DIV, your users are clicking. With that curiosity in mind, I've created HeatMap: a MooTools class that allows you to detect, load, save, and...
In the five years I've been at Mozilla I've seen some awesome projects. Some of them very popular, some of them very niche, but none of them has inspired me the way the MozVR team's work with WebVR and A-Frame project have.
A-Frame is a community project...