Re: Date maths
| From: | Paul Scott | Date: | Mon, 11 Sep 2006 05:34:16 +0000 |
| Subject: | Re: Date maths | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241573@lists.php.net to get a copy of this message | ||
Dave,
Luckily for you there is a whole whack of functions made specifically
for these issues...
On Sun, 2006-09-10 at 21:19 +0100, Dave Goodchild wrote:
> So, when an event-holder enters a repeating event, the main event details
> are held in the events table, and all the relevant dates for the event (they
> specify the first date of the event and the last date it is to be held) are
> entered into the calendar table by increment (ie timestamp intervals by 24
> hours, 7 days or monthly, and I know monthly is going to be tricky as it is
> a fluctuating interval).
>
Have a look at the PHP manual entries for date() and strtotime(). There
are a few others, but this should get you well started!
There is also a PEAR::Date object that you may find useful, as well as a
calendar object IIRC.
There are a few basics that you want to keep in mind though:
1. strtotime works well, but make sure that your date/time strings
conform to the GNU datetime specs.
2. There are 86400 seconds in a day.
3. Date also accepts parameters like +1month and -1month, this works for
days, weeks, months etc.
4. Google "php calendar class and php date class" you will get like a
bazillion resources that will really help out.
HTH a bit...
--Paul