To give you an idea of what to avoid doing, here are a few mistakes most of us are guilty of on Bumble.The valid range of a timestamp is typically from Fri, GMT to Tue, GMT.
James was looking for a way to calculate the number of days which have passed since a certain date.
Rather than using mktime() and a loop, James can subtract the current timestamp from the timestamp of the date in question and divide that by the number of seconds in a day: Another usage could find itself in a class submitted by Kyle M Hall which aids in the creation of timestamps from the recent past for use with My SQL.
Rather than the looping and fine tuning of a date, Kyle can use the raw UNIX timestamps (this is untested code): In order to define leap year you must considre not only that year can be divide by 4!
The correct alghoritm is:if (year is not divisible by 4) then (it is a common year)else if (year is not divisible by 100) then (it is a leap year)else if (year is not divisible by 400) then (it is a common year)else (it is a leap year)So the code should look like this:if($year%4 == 0 && $year0 !
(These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer).