Re: Time Processing
| From: | James, Yz | Date: | Sun, 14 Oct 2001 09:29:31 +0000 |
| Subject: | Re: Time Processing | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71025@lists.php.net to get a copy of this message | ||
Hey,
"A. R. M." <amojahed@uwo.ca> wrote in message
news:Pine.SOL.4.21.0110140153550.24872-100000@panther.uwo.ca...
> Hi,
>
> As I said, PHP doesn't seem to have enough built-in functions to process
> time values.
> So, I wrote my own functions to deal with times and I'm posting them here
> for either inclusion, or for other people's use.
>
> Here they are. Enjoy.
> =====================
>
> <?php
> function CheckTime($t) {
> /* Checks the value of a 24-hour formatted time to be correct.
> Returns 0 if bad time format, 1 otherwise.
> */
> return ( ereg("[012][0-9]:[0-5][0-9](:[0-5][0-9])?", $t) );
> }
You'd need to adjust this, because by your regex, 29:00:00 would be a valid
time.
> /* I have no idea why mktime behaves this way, but I had to deduct 5 hours
> to make it work right. As if it's returned in GMT.
> */
Rather than subtracting a set value from this, use the time offset format of
the date() function to get the difference (especially if in an area where
daylight savings schemes are in effect - Z I believe:
http://www.php.net/manual/en/function.date.php).
Too tired to read through the rest, but hopefully that's off some use to you
:-)
James