I study, so the question may seem silly)) There is a script that outputs data from the mysql database, everything works, only there is one moment - the work shift from 9:00 am to 9:00 the next day, I need to write from the night of the next day , until 9:00 got into the previous day. The picture should be clear, i.e. entries from the 31st, should have been in 30, because they were made before 09:00 in the morning ... Tell me how you can implement!? Thank!

enter image description here

if ($_POST["go"]) {//ΠžΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° Ρ„ΠΎΡ€ΠΌΡ‹ ΠΏΠΎ Π½Π°ΠΆΠ°Ρ‚ΠΈΡŽ ΠΊΠ½ΠΎΠΏΠΊΠΈ $start_date = $get_year1."-".$get_mounf1."-".$get_day1." ".$get_hour1.":".$get_min1; $stop_date = $get_year2."-".$get_mounf2."-".$get_day2." ".$get_hour2.":".$get_min2;} if ($_GET[start_date] AND $_GET[stop_date]) {//ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° Ρ„ΠΎΡ€ΠΌΡ‹ ΠΈΠ· Π²Π½Π΅, замСняСм ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰ΠΈΠ΅ значСния ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ $start_date = $_GET[start_date]." ".$_GET[start_time]; $stop_date = $_GET[stop_date]." ".$_GET[stop_time];} print $start_date." -- ".$stop_date."<br>"; //провСрочная строка $result = mysql_query("SELECT * FROM history WHERE start_work BETWEEN '$start_date' AND '$stop_date' ORDER BY `history`.`start_work` DESC"); ?><table class="bordered"><tr> <th width="71"><div align="center"><b><i>Π”Π°Ρ‚Π°</i></b></div></th> <th width="74"><div align="center"><b><i>ВрСмя</i></b></div></th> <th width="212"><b><i>Услуга</b></th> <th width="82"><div align="center"><b><i>Π‘Ρ‚ΠΎΠΈΠΌΠΎΡΡ‚ΡŒ</i></b></div></th> <th width="135"><div align="center"><b><i>Π‘ΠΎ скидкой</i></b></div></th> <th width="276"><b><i>ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΠ΅</i></b></th> </tr><? while ($row=mysql_fetch_array($result)){ $sale = $row[sale]; $note = $row[note]; $row_id = $row[id]; $str_start_work = $row[start_work]; $arr_start_work = explode(" ", $str_start_work); //Ρ€Π°Π·Π±ΠΈΠ²Π°Π΅ΠΌ строку start_work Π½Π° Π΄Π°Ρ‚Ρƒ ΠΈ врСмя $start_work_date = $arr_start_work[0]; //ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ Π΄Π°Ρ‚Ρƒ $start_work_time = $arr_start_work[1]; //ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ врСмя $arr_date = explode("-", $start_work_date); $year_date = $arr_date[0]; //Π³ΠΎΠ΄ $mounf_date = $arr_date[1]; //мСсяц $day_date = $arr_date[2]; //дСнь $arr_time = explode(":", $start_work_time); $h_time = $arr_time[0]; //часы $m_time = $arr_time[1]; //ΠΌΠΈΠ½ΡƒΡ‚Ρ‹ //---------------------- Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ ------------------------------ // if (!$m_title OR $m_title != $mounf_date){ ?><tr><td colspan="6"><div align="center"><b><?=$mounf_name[str_replace('0', '', $mounf_date)]." ".$year_date;?></b> [<a href="visual.php?date=<?=$mounf_date."-".$year_date;?>" onclick="window.open(this.href, '', 'scrollbars=1,height='+Math.min(400, screen.availHeight)+',width='+Math.min(525, screen.availWidth)); return false;">сводная Ρ‚Π°Π±Π»ΠΈΡ†Π°</a>]</div></tr><? } if (!$m_day OR $m_day != $day_date){ ?><tr><td colspan="6"><div align="center"><b><?=$day_date."/".$mounf_date."/".$year_date;?></b> [<a href="visual.php?day=<?=$day_date;?>&date=<?=$mounf_date."-".$year_date;?>" onclick="window.open(this.href, '', 'scrollbars=1,height='+Math.min(400, screen.availHeight)+',width='+Math.min(525, screen.availWidth)); return false;">сводная Ρ‚Π°Π±Π»ΠΈΡ†Π°</a>]</div></tr><? } //---------------------- !Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ ------------------------------ // //---------------------- Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ строчки ------------------------------ // ?> <td width="71"><div align="center"><?=$day_date."/".$mounf_date."/".$year_date;?></div></td> <td width="74"><div align="center"><?=$h_time.":".$m_time;?></div></td> <td width="212"><? $row = explode("/", $row['type']); $i_pp=1; foreach($row as $t_row){ if ($i_pp == '1'){ $t_price='0'; } list($u_name, $u_cat, $u_price) = explode(":", $t_row); //ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌ сумму if ($u_name){ print "<nobr>".$i_pp.". ".$u_name." (ΠΊΠ°Ρ‚. ".$u_cat.")</nobr><br>"; }//if $i_pp++; $t_price = $u_price+$t_price; }//for ?></th> <td width="82"><div align="center"><?=number_format($t_price, 0, ',', ' ');?>Ρ€.</div></td> <td width="135"><div align="center"><? if ($sale){ print number_format($t_price-($t_price/100*$sale), 0, ',', ' ')."Ρ€."; }else{ print "Π½Π΅Ρ‚ скидки"; } ?></div></td> <td width="276"> <a style='text-decoration: none; float:left;' href="note.php?id=<?=$row_id;?>" onclick="window.open(this.href, '', 'scrollbars=1,height='+Math.min(400, screen.availHeight)+',width='+Math.min(525, screen.availWidth)); return false;"><font color='green'>&#9998;</font></a> <?=$note;?></td> </tr> <? //---------------------- Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ строчки ------------------------------ // $m_title = $mounf_date; $m_day = $day_date; }//while 

  • one
    Subtract from the date of 9 hours. ( date - interval 9 hour ) - Mike
  • unfortunately, for the time being this tells me little (( - Dimastik86
  • In the WHERE section of the query, add the same 9 hours to the $ start_date and $ stop_date values. - Akina
  • one
    If you do not separate HTML and PHP code into different files, it will be very difficult to figure it out later, it will take a lot of time, especially if the knowledge of languages ​​is very small. - ilyaplot

0