Re: Re: [PHP] String to Date and Date to String Functions?
| From: | Ben Edwards | Date: | Tue, 25 Jan 2005 00:24:44 +0000 |
| Subject: | Re: Re: [PHP] String to Date and Date to String Functions? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207190@lists.php.net to get a copy of this message | ||
On Mon, 24 Jan 2005 20:15:15 -0000, Ford, Mike <M.Ford@leedsmet.ac.uk> wrote:
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
>
> On 24 January 2005 19:01, Ben Edwards wrote:
>
> > On Mon, 24 Jan 2005 12:58:52 -0500, hitek@cox.net
> > <hitek@cox.net> wrote:
> > > How about the strtotime() function?
> > > http://us4.php.net/manual/en/function.strtotime.php
> >
> > No good, it douse not take a format string. What if I wanted to
> > convert the timestamp to 'DD-MM-YYY', display it on a form, validate
> > it, and then convert it back to a timestamp.
>
> Well, if you're going to validate it, you'll have to figure out which bits
> are the day, month and year -- having done that, you'll have them as three
> separate bits of information, so you can use mktime() on them, or glue them
> back together to feed to strtotime() in one of the various formats it
> recognizes. Seems to me a format string is pretty irrelevant in all of
> this.
Different users have can have the date displayed in there local form.
And no, I dont have to split the date up, the date() function should
be able to be used to validate the date. I asume it returns null, or
something sensable, if the date is invalid. Anyway as the date format
is user defined I need both functions.
> Speaking for myself personally, I would never accept a wholly textual date
> from a form -- I would have drop-downs for the day and month, and maybe also
> for the year depending on the valid range, and then it's a snap just to hand
> the resulting values to mktime().
In this case it is a back end administration form as the (power) user
does not want to have to fiddle about with drop downs. In fact they
can use / or - or . as a seperater. The split function can handle
that.
L8r,
ben
> Cheers!
>
> Mike
>
> ---------------------------------------------------------------------
> Mike Ford, Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Headingley Campus, LEEDS, LS6 3QS, United Kingdom
> Email: m.ford@leedsmet.ac.uk
> Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
>
--
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)