Convert time to unix

Hi guys,

I am trying to convert a time to a unix time stamp my code below: is producing incorrect results:


<?php

$x =  ("03:14:59:20");
$y =  ("01:16:01:02");
echo "Fist time:".$x."<$xbr/><br/>";
echo "Second time:".$y."<br/><br/>";
$now = explode(":",$x);      // gives us $now[0]=>2005, $now[1]=>11, $now[2] => 20
$now2 = explode(":",$y);      // gives us $now[0]=>2005, $now[1]=>11, $now[2] => 20
$now = mktime(0,0,0,$now[1],$now[2],$now[0]);   // make unix timestamp -must be month day year (www.php.net)
$now2 = mktime(0,0,0,$now[1],$now[2],$now[0]);   // make unix timestamp -must be month day year (www.php.net)
$now3 = $now - $now2;
echo $now."   minus   ".$now2." equals:  ".$now3."<br/>"; 
$date_array = getdate($now3);
echo "The time is:".$date_array['hours'].":".$date_array['minutes'].":".$date_array['seconds'];
?>


Can anyone suggest a correct and more efficient way of doing this.

PHP: strtotime - Manual

Hi thanks but I don’t know how to use this for frames as in;

20:34:12:23

It doesn’t specify a parameter to pass for this

Where are year, month, day coming from?

You declare this:


$x =  ("03:14:59:20");

and then reference it here;


$now = explode(":",$x);      // gives us $now[0]=>2005, $now[1]=>11, $now[2] => 20

Which I cannot follow…