Hi all,

I am working with a legacy system which for whatever reason was wriiten to produce time output in a decimal format and not a time format. So I am attempting to convert it to a usable format. During the process the script adds one hour (in seconds)

Example: Decimal time output: 1454.

I am spliting the output into an array with two parts, hours and mins.

I then calculate the number of seconds in the hours part followed by the seconds part. This give me the number of seconds in the output.

I then find the current time and add the number of seconds from the array. Then by adding to two together I have a timestamp which I then convert to a readable format.

My big question is; I am I doing this correctly because the result is a date and time less than the original time and I need it to be greater.

$EstimatedDateTime = "1337";
$msg = str_split($EstimatedDateTime);

$hours = $msg[0]."".$msg[1];
$mins = $msg[2]."".$msg[3];
$extrahour = $hours + 1;

$del_time_sec = (($extrahour *60) +$mins) * 60;
$nowTime = time();
$DeleteTime = $del_time_sec + $nowTime

print date("Y-m-d h:i:s" ,$DeleteTime);

    [MAN]strtotime[/MAN] is your best friend here. For example:

    echo date( 'y-m-d h:i:s', strtotime( '1337' ));
    

      Hi Shrike,

      Thanks for your reply, I will give that a go.

        Write a Reply...