inbuilt PHP function to check date and time.

inbuilt PHP function to check date and time.

am 03.10.2007 14:25:10 von vivek.j.joshi

Hello Friends,
There is a PHP function checkdate to check if a date is a valid
Gregorian date.
Is there any such function to check for a valid time like something in
hh:mm:ss format? If not, can we use any existing date and time
functions to validate a time string like '15:45:56'?

I am unable to get an answer. If anyone knows the answer, it would be
very grateful.

Thanks you for reading this post.

Sincerely,
Wizard.

Re: inbuilt PHP function to check date and time.

am 03.10.2007 18:38:57 von Michael Fesser

..oO(wizard)

>Is there any such function to check for a valid time like something in
>hh:mm:ss format? If not, can we use any existing date and time
>functions to validate a time string like '15:45:56'?

It's easy enough to write such a function. You could split the string
with explode() and then check its three parts for the correct ranges
(0-23, 0-59, 0-59).

Micha

Re: inbuilt PHP function to check date and time.

am 03.10.2007 22:22:52 von Patrick Brunmayr

On 3 Okt., 18:38, Michael Fesser wrote:
> .oO(wizard)
>
> >Is there any such function to check for a valid time like something in
> >hh:mm:ss format? If not, can we use any existing date and time
> >functions to validate a time string like '15:45:56'?
>
> It's easy enough to write such a function. You could split the string
> with explode() and then check its three parts for the correct ranges
> (0-23, 0-59, 0-59).
>
> Micha

http://at2.php.net/manual/en/function.checkdate.php