PHP - 延长时钟以显示 23-24-25 而不是 23-00-01

PHP - Extend clock to show 23-24-25 instead of 23-00-01

好的,这是我在这里的第一个问题,所以请大发慈悲。我正在开发一个 Web 应用程序来增加我在 PHP 编程方面的知识,但是我遇到了一个问题。

我的 webapp 是由时间驱动的。因此,例如当时钟为 17:00 时,它显示了一条存储在多维数组中的信息。当时钟为 18:30 时,它会在数组中显示一些其他信息。问题是我有一些信息需要显示在例如 25:12 而不更改当前日期。

所以问题: 您能否允许时钟将时间显示为 24:00-25:00-26:00 而不是 00:00-01:00-02:00 而仍然是同一天?比方说时钟是 26:00 之后,这一天将从星期一更改为星期二?

这是一个多维数组的例子。它一直工作到 23:59,但时钟当然只上升到 00:00,而且日期当然在变化。那你能"extend"在PHP那一天吗?

示例:

//This is one of the arrays I´ve got. This one only works on Monday-Friday. 
//It´s called "H103.php
$tur = array
(
array("RYEV", "6:26", "Møt", 1),
array("RYEV", "6:36", "Uttak", 1),
array("RYE2", "6:39+", "N", 1),
array("FRS2", "7:29", "D", 1),
array("FRS1", "7:43", "N", 1),
array("BKR1", "8:47+", "N", 1),
array("FRS2", "9:44", "D", 1),
array("FRS1", "9:58", "N", 1),
array("BKR1", "11:02+", "N", 1),
array("FRS2", "11:59", "D", 1),
array("FRS1", "12:13", "N", 1),
array("BKR1", "13:17+", "N", 1),
array("FRS1", "14:14", "D", 1),
array("FRS1", "14:28", "N", 1),
array("BKR1", "15:32+", "N", 1),
array("FRS2", "16:29", "D", 1),
array("FRS1", "16:43", "N", 1),
array("BKR1", "17:47+", "N", 1),
array("FRS2", "18:44", "D", 1),
array("FRS1", "18:58", "N", 1),
array("HFY2", "20:00+", "N", 1),
array("FRS2", "20:44", "D", 1),
array("FRS1", "20:58", "N", 1),
array("HFY2", "22:00+", "N", 1),
array("FRS2", "22:44", "D", 1),
array("FRS1", "22:58", "N", 1),
array("HFY2", "24:00+", "N", 1),
array("FRS2", "24:47", "D", 1),
array("MAJ3", "25:15", "D", 1),
array("AVL2", "25:35", "D", 1),
array("SPO6", "25:38", "Inn", 1),
);

//Define time into variable and counts array in total.
$klokkeT = date("H:i");
$antT = count($tur);
$u = 0;

//Finding out which line from the array to take based on time, 
//and the storing it in a variable to show it on the website. 

if ($_SESSION["kjoreLinje"] == 1 && $_SESSION["retning"] == "O"){
for ($m = 0; $m < $antT; $m++) {
   $u++;
    if ($u < $antT) {
        if ($klokkeT >= $tur[$m][1] AND $klokkeT <= $tur[$u][1]) {
            $turF1 = $tur[$m][0]; $turF2 = $tur[$m][1]; $turF3 = $tur[$m][2];
            $turF4 = $tur[$m][3]; $turN1 = $tur[$u][0]; $turN2 = $tur[$u][1];
            $turN3 = $tur[$u][2]; $turN4 = $tur[$u][3];
        } } }

//System choosing which file to take based on what day it is
$weekdays =  array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday");

//weekdays
for ($i = 0; $i < 5; $i++){
 if ($_SESSION["day"] == $weekdays[$i]) {
        if ($_SESSION["togNr"] == 103) {
        include_once 'Kjoretavler/Hverdag/Linje1/H103.php'; }
//Saturday
if ($_SESSION["dag"] == "Saturday") {
        if ($_SESSION["togNr"] == 103) {
        include_once 'Kjoretavler/Lordag/Linje1/L103.php'; }
//Sunday
if ($_SESSION["dag"] == "Sunday") {
        if ($_SESSION["togNr"] == 103) {
        include_once 'Kjoretavler/Sondag/Linje1/S103.php'; }

我得到了@Andreas 的回答,需要进行一些修改。似乎他已经删除了他的答案,所以我不能给他应得的荣誉。再次感谢,抱歉解释不当。我已经学到了很多东西。编辑:对我有用的代码。

  if (date("G") <= 3) {
    $day = Date("l", strtotime("yesterday"));
    $time = 24 + intval(date("G")) . date(":i");
} else {
    $day = date("l");
    $time = date("G:i");
}
echo $day . " \n";
echo $time;