RE: [PHP] Validate The Last Day of Month with server's clock????
| From: | Ford, Mike [LSS] | Date: | Thu, 14 Aug 2003 17:20:16 +0000 |
| Subject: | RE: [PHP] Validate The Last Day of Month with server's clock???? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159599@lists.php.net to get a copy of this message | ||
On 14 August 2003 16:01, Scott Fletcher wrote:
> "Mike Ford" <M.Ford@lmu.ac.uk> wrote in message
>
> news:841D90E489448A4F804E1D1B95768BF7D461A6@lis-exchange3.lmu.ac.uk...
> > On 13 August 2003 20:05, Nicholas Robinson wrote:
> >
> > > On Wednesday 13 Aug 2003 8:00 pm, Scott Fletcher wrote:
> > > > Hi!
> > > >
> > > > Here's a trick script. We know that some months have the
> > > > last day which is 30 while other is 31. As for February, it
> > > > can be either 28 or 29. So, what's the trick in using the php
> > > > to find out what is the last day of the month if you want to
> > > > checked it against the server's clock to find out the last day
> > > > of the month. Suppose it is this month or 3 months ago or 3
> > > > months from now. Anyone know?
> > >
> > > The 'usual' trick is to set the date to the first day of the month
> > > after the one you want and then subtract one day.
> >
> > Actually, the "usual" trick is to ask mktime() for the 0th
> day of the
> following month. One of the examples on the mktime() page of the
> manual (http://www.php.net/mktime) even illustrates exactly this.
>
> True but I just only want the day date, don't want the number of
> seconds.
So use one of the other Date/Time functions to to convert it back to
whatever you do want -- date(), getdate() and strftime() all accept a
timestamp produced by mktime() as an optional parameter.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211