Re: Time to Calculate Time
| From: | vins | Date: | Mon, 08 Jul 2002 15:59:02 +0000 |
| Subject: | Re: Time to Calculate Time | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-106105@lists.php.net to get a copy of this message | ||
That looks great.
But why do you have to carage the line after 3 in the function ?
"Danny Shepherd" <danny@kyboshed.com> wrote in message
news:022001c22696$087e4cc0$0200a8c0@DANNYS...
> You just knew there was a regexp version on the way, didn't you :)
>
> Danny.
>
> <?php
>
> function unixTime($time)
> {
> $time=preg_replace('/(.{4})(.{2})(.{2})(.{2})(.{2})(.{2})/','\\1/\\2/\\3
> \\4:\\5:\\6',$time);
> return strtotime($time);
> }
>
> $time1='20020707140000';
> $time2='20020707160000';
>
> $timeDiff=unixTime($time2)-unixTime($time1);
>
> echo "The two times are $timeDiff seconds apart";
> ?>
>
>
>