RE: Re: String to Date and Date to String Functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx
> <hitek@xxxxxxx> 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.

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().

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@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux