problem displaying 24:00:00 time

hi
i have this funtion which create a select option in intervals of 30 minutes. it works, but it will not display 24:00:00 but 00:00:00
how can i fix it?
function timeSelect($start,$end)
{

$tStart = strtotime($start);
$tEnd = strtotime($end);
$tNow = $tStart;

while($tNow <= $tEnd){

 $option = '<option value="'.date("H:i:s",$tNow).'">'.date("H:i:s",$tNow).'</option>';
  //echo date("H:i:s",$tNow)."\n";
  echo $option;
  $tNow = strtotime('+30 minutes',$tNow);
 
}

}

Open in new window

best regards
LVL 1
derridaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mukesh YadavFull Stack DeveloperCommented:
Because 24:00:00 is not a valid time.
derridaAuthor Commented:
hi
i know that it isn't, yet i have been asked to display 24:00:00 so i am asking is there a way, within this function.

Prior to PHP 5.3.0, 24:00 was not a valid format and strtotime() returned FALSE.
Ray PaseurCommented:
"Prior to PHP 5.3" is a long time, many years ago.  Even PHP 5.5 is obsolete today.  It's time to upgrade!

You just have to change the programming.  The clock runs from 00:00:00 to 23:59:59, then it rolls back to 00:00:00.  So test for 00:00:00 and use str_replace() or an assignment statement to change it to 24:00:00.  But don't blame us if your clients call and tell you to fix it!
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Ray PaseurCommented:
Please see: http://iconoun.com/demo/temp_derrida.php
<?php // demo/temp_derrida.php

/**
 * Demonstrate a mung of the standard ISO-8601 Date / Time string
 * http://www.experts-exchange.com/questions/28692356/problem-displaying-24-00-00-time.html
 */
error_reporting(E_ALL);
echo '<pre>';


// UPDATED FROM THE POST AT EE
function timeSelect($start, $end)
{
    $tStart = strtotime($start);
    $tEnd = strtotime($end);
    $tNow = $tStart;

    while($tNow <= $tEnd)
    {
        $printable_tNow = date("H:i:s",$tNow);
        if ($printable_tNow == '00:00:00') $printable_tNow = '24:00:00';
        $option = '<option value="' . $printable_tNow . '">' . $printable_tNow . '</option>' . PHP_EOL;
        echo $option;
        $tNow = strtotime('+30 minutes',$tNow);
    }
}


// TEST THE UPDATED FUNCTION
TimeSelect('Today 10:30pm', 'Tomorrow 1:30am');

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
derridaAuthor Commented:
thanks ray, always great help
Ray PaseurCommented:
Glad to help.  Thanks for the points! ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.