FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Verifying time in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Verifying time in php [message #179385 is a reply to message #179382] Sun, 14 October 2012 16:41 Go to previous messageGo to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Sun, 14 Oct 2012 17:50:48 +0200, Michael Fesser wrote:
> .oO(houghi)
>
>> I am aware of those. However I can not figure out how to do a check on
>> all of them, without getting lost in if statements.
>>
>> See below where '-' means empty, 1 means any digit(s) and A means any no
>> digit(s). I have not shown all options.
>> [...]
>
> I wouldn't care too much about invalid inputs. Instead I would just take
> what I get and see what I can do with it.
>
> So I would explicitly cast all values to int (invalid or empty values
> will become 0), then just do a simple range check on all of the three
> values and then do the math.

Challenging curcumstance: "A" "B" "C" cast to int becomes 0:0:0, which
is a valid time.

Use the values submitted to make a valid format to throw at strptime()
perhaps... If it returns FALSE, it's not a valid time. Anything else is.

--
It is impossible to sharpen a pencil with a blunt axe. It is equally
vain to try to do it with ten blunt axes instead
--E.W Dijkstra, 1930-2002
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Curl chmod file transfer problem...
Next Topic: test
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 11:06:41 GMT 2024

Total time taken to generate the page: 0.04170 seconds