Skip to content

Commit 617e6c8

Browse files
committed
Add a PHP solution to problem 166
1 parent f5c9b8d commit 617e6c8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
date_default_timezone_set('UTC');
5+
6+
$inputFile = new SplFileObject($argv[1]);
7+
8+
$inputFile->setFlags(SplFileObject::READ_CSV |
9+
SplFileObject::READ_AHEAD |
10+
SplFileObject::SKIP_EMPTY |
11+
SplFileObject::DROP_NEW_LINE);
12+
13+
$inputFile->setCsvControl(' ');
14+
15+
foreach($inputFile as $time)
16+
{
17+
$time = array_map(function($timestamp)
18+
{
19+
return new DateTime($timestamp);
20+
}, $time);
21+
22+
echo $time[0]->diff($time[1])->format('%H:%I:%S'), PHP_EOL;
23+
}

0 commit comments

Comments
 (0)