根据字符串获取最接近(过去)的时间

I want to create a function that can find the closest time, based in a string of second.

The system will receive an int number that equivalent of second of that time. PHP must find the closest (in past) date.

Example:

//supose that an anterior script created it at "14-08-25 10:32:30"
//and now it's "14-08-25 10:33:12"
$seconds = 30; // the variable passed from an anterior script
$time_received= date('Y-m-d H:i:s'); // this is the time that I'll receive this 
//so, from these 2 variables above, i must find "14-08-25 10:32:30"

Anyone have an idea how to do this?

I have just these variables: The time right now, that is "14-08-25 10:33:12" and the $seconds variable.

With these 2, I want to get "14-08-25 10:32:30"

It isn't completely clear to me what you are trying to accomplish, but I'm making a guess by using strtotime():

<?php
$seconds = 30;
$time = strtotime("-" . $seconds . " seconds");
echo date( "Y-m-d H:i:s", $time );
?>

Found. I'm using this script:

$seconds = 30; 
$new_date = new DateTime(date()); //the only two variables that i have

if($new_date->format('s')<$seconds){
    $new_date->setTime($new_date->format('H'),$new_date->format('i')-1,$seconds);
    $old_date = $new_date->format('Y/m/d H:i:s');
}else{
    $new_date->setTime($new_date->format('H'),$new_date->format('i'),$seconds);
    $old_date = $new_date->format('Y/m/d H:i:s');
}