将x小时x分钟前转换回unix时间戳

I'm looking for a function to convert dates presented in "X Hours ago" and "X minutes ago" back into a timestamp in php, anyone have a soulution to this?

strtotime already does this:

$timestamp = strtotime("8 hours ago");

See relative time format specifications for more info.

$hourago= "-1 hour";
$minago = "-2 minute";

$timestamp = strtotime($hourago.' '.$minago);
echo $timestamp;

or

$hourago= "-1";
$minago = "-2";

$timestamp = strtotime($hourago.' hour '.$minago.' minute');
echo $timestamp;

I helped someone on stackoverflow to write a function that does the reverse of this, here is the code, i'm sure if you deconstruct and reverse it, you will have your answer:

<?
$unix_time = 6734;
echo howLongAgo($unix_time);

function howLongAgo($time_difference){

// Swtich logic based on the time difference passed to this function, sets the english string and what number the difference needs to be divided by
    switch($time_difference){
         case ($time_difference < 60):
              $string = " second";
              break;
         case ($time_difference >= 60 && $time_difference < 3600):
              $string = " minute";
              $divider = 60;
              break;
         case ($time_difference >= 3600 && $time_difference < 86400):
              $string = " hour";
              $divider = 3600;
              break;
         case ($time_difference >= 86400 && $time_difference < 2629743):
              $string = " day";
              $divider = 86400;
              break;
         case ($time_difference >= 2629743 && $time_difference < 31556926):
              $string = " month";
              $divider = 2629743;
              break;
         case ($time_difference >= 31556926):
              $string = " year";
              $divider = 31556926;
              break;
    }

// If a divider value is set during the switch, use it to get the actual difference
if($divider){$diff = round($time_difference / $divider);}else{$diff = round($time_difference);}
// If the difference does not equal 1, pluralize the final result EG: hours, minutes, seconds
if($diff != 1){$pluralize="s";}
// Concatenate all variables together and return them
$final =  $diff . $string . $pluralize . " ago";
return $final;

}
?>