Как правильно вывести дату? Программистам-ньюбам посвящается

12
pelvis
На сайте с 01.09.2005
Offline
345
985

<?php
$chislo=date(d);
$mec=date(m);
$god=date(Y);
$hour=date(G);
$min=date(i);
$hour_prov=$hour+1;
$min_add=$min+10;
if ($min_add>60) {$min_add=60- ($min_add-60);}
?>

<select name="date" >
<option></option>
<option <?php if ($chislo=="1") {print "selected"; } else {if ($_POST[date]=="01") {print "selected";}} ?> >01</option>
<option <?php if ($chislo=="2") {print "selected"; } else {if ($_POST[date]=="02") {print "selected";}} ?>>02</option>
<option <?php if ($chislo=="3") {print "selected"; } else {if ($_POST[date]=="03") {print "selected";}} ?>>03</option>
<option <?php if ($chislo=="4") {print "selected"; } else {if ($_POST[date]=="04") {print "selected";}} ?>>04</option>
<option <?php if ($chislo=="5") {print "selected"; } else {if ($_POST[date]=="05") {print "selected";}} ?>>05</option>
<option <?php if ($chislo=="6") {print "selected"; } else {if ($_POST[date]=="06") {print "selected";}} ?>>06</option>
<option <?php if ($chislo=="7") {print "selected"; } else {if ($_POST[date]=="07") {print "selected";}} ?>>07</option>
<option <?php if ($chislo=="8") {print "selected"; } else {if ($_POST[date]=="08") {print "selected";}} ?>>08</option>
<option <?php if ($chislo=="9") {print "selected"; } else {if ($_POST[date]=="09") {print "selected";}} ?>>09</option>
<option <?php if ($chislo=="10") {print "selected"; } else {if ($_POST[date]=="10") {print "selected";}} ?>>10</option>
<option <?php if ($chislo=="11") {print "selected"; } else {if ($_POST[date]=="11") {print "selected";}} ?>>11</option>
<option <?php if ($chislo=="12") {print "selected"; } else {if ($_POST[date]=="12") {print "selected";}} ?>>12</option>
<option <?php if ($chislo=="13") {print "selected"; } else {if ($_POST[date]=="13") {print "selected";}} ?>>13</option>
<option <?php if ($chislo=="14") {print "selected"; } else {if ($_POST[date]=="14") {print "selected";}} ?>>14</option>
<option <?php if ($chislo=="15") {print "selected"; } else {if ($_POST[date]=="15") {print "selected";}} ?>>15</option>
<option <?php if ($chislo=="16") {print "selected"; } else {if ($_POST[date]=="16") {print "selected";}} ?>>16</option>
<option <?php if ($chislo=="17") {print "selected"; } else {if ($_POST[date]=="17") {print "selected";}} ?>>17</option>
<option <?php if ($chislo=="18") {print "selected"; } else {if ($_POST[date]=="18") {print "selected";}} ?>>18</option>
<option <?php if ($chislo=="19") {print "selected"; } else {if ($_POST[date]=="19") {print "selected";}} ?>>19</option>
<option <?php if ($chislo=="20") {print "selected"; } else {if ($_POST[date]=="20") {print "selected";}} ?>>20</option>
<option <?php if ($chislo=="21") {print "selected"; } else {if ($_POST[date]=="21") {print "selected";}} ?>>21</option>
<option <?php if ($chislo=="22") {print "selected"; } else {if ($_POST[date]=="22") {print "selected";}} ?>>22</option>
<option <?php if ($chislo=="23") {print "selected"; } else {if ($_POST[date]=="23") {print "selected";}} ?>>23</option>
<option <?php if ($chislo=="24") {print "selected"; } else {if ($_POST[date]=="24") {print "selected";}} ?>>24</option>
<option <?php if ($chislo=="25") {print "selected"; } else {if ($_POST[date]=="25") {print "selected";}} ?>>25</option>
<option <?php if ($chislo=="26") {print "selected"; } else {if ($_POST[date]=="26") {print "selected";}} ?>>26</option>
<option <?php if ($chislo=="27") {print "selected"; } else {if ($_POST[date]=="27") {print "selected";}} ?>>27</option>
<option <?php if ($chislo=="28") {print "selected"; } else {if ($_POST[date]=="28") {print "selected";}} ?>>28</option>
<option <?php if ($chislo=="29") {print "selected"; } else {if ($_POST[date]=="29") {print "selected";}} ?>>29</option>
<option <?php if ($chislo=="30") {print "selected"; } else {if ($_POST[date]=="30") {print "selected";}} ?>>30</option>
<option <?php if ($chislo=="31") {print "selected"; } else {if ($_POST[date]=="31") {print "selected";}} ?>>31</option>
</select>
<select name="month">
<option></option>
<option <?php if ($mec=="01") {print "selected"; } else {if ($_POST[month]=="январь") {print "selected";}} ?>>январь</option>
<option <?php if ($mec=="02") {print "selected"; } else {if ($_POST[month]=="февраль") {print "selected";}} ?>>февраль</option>
<option <?php if ($mec=="03") {print "selected"; } else {if ($_POST[month]=="март") {print "selected";}} ?>>март</option>
<option <?php if ($mec=="04") {print "selected"; } else {if ($_POST[month]=="апрель") {print "selected";}} ?>>апрель</option>
<option <?php if ($mec=="05") {print "selected"; } else {if ($_POST[month]=="май") {print "selected";}} ?>>май</option>
<option <?php if ($mec=="06") {print "selected"; } else {if ($_POST[month]=="июнь") {print "selected";}} ?>>июнь</option>
<option <?php if ($mec=="07") {print "selected"; } else {if ($_POST[month]=="июль") {print "selected";}} ?>>июль</option>
<option <?php if ($mec=="08") {print "selected"; } else {if ($_POST[month]=="август") {print "selected";}} ?>>август</option>
<option <?php if ($mec=="09") {print "selected"; } else {if ($_POST[month]=="сентябрь") {print "selected";}} ?>>сентябрь</option>
<option <?php if ($mec=="10") {print "selected"; } else {if ($_POST[month]=="октябрь") {print "selected";}} ?>>октябрь</option>
<option <?php if ($mec=="11") {print "selected"; } else {if ($_POST[month]=="ноябрь") {print "selected";}} ?>>ноябрь</option>
<option <?php if ($mec=="12") {print "selected"; } else {if ($_POST[month]=="декабрь") {print "selected";}} ?>>декабрь</option>
</select>
<select name="year">
<option <?php if (isset($otpravka_zakaz)) {print "$god"; } else {if ($_POST[year]=="2006") {print "selected";}} ?>>2006</option>
<option <?php if (isset($otpravka_zakaz)) {print "$god"; } else {if ($_POST[year]=="2007") {print "selected";}} ?>>2007</option>
<option <?php if (isset($otpravka_zakaz)) {print "$god"; } else {if ($_POST[year]=="2008") {print "selected";}} ?>>2008</option>
<option <?php if (isset($otpravka_zakaz)) {print "$god"; } else {if ($_POST[year]=="2009") {print "selected";}} ?>>2009</option>
<option <?php if (isset($otpravka_zakaz)) {print "$god"; } else {if ($_POST[year]=="2010") {print "selected";}} ?>>2010</option>
</select>

Как Вам это??? Мы тут пытаемся оптимизировать сайт один и наткнулись :bl:

Продаю вывески. Задарма и задорого (https://www.ledsvetzavod.ru/)
AM
На сайте с 04.11.2003
Offline
57
#1

Ниосилил... но сильно! Респект нубу. Столько Copy-Paste делать!

mymind
На сайте с 07.09.2004
Offline
188
#2

Я всегда думал, что циклы изучают однин из первых.

ewg
На сайте с 18.01.2006
Offline
121
ewg
#3

Душевно... :D

С Уважением, Евгений
Hartamon
На сайте с 04.07.2006
Offline
165
#4

Даешь ассемблер!!!!

СКОРПИОН
На сайте с 05.01.2006
Offline
120
#5

В ассемблере макросы есть... ;)

• Контекстные ссылки с внутренних страниц навсегда (/ru/forum/370882) • Качественные сайты для заработка на контекстной рекламе и ссылках
dkameleon
На сайте с 09.12.2005
Offline
386
#6

В тему про даты, если кто ещё не видел:

Программистский шедевр на индусском форуме на тему "как узнать завтрашнюю дату" остался непревзойденным:

void get_tomorrow_date( struct timeval *date )

{

sleep( 86400 ); // 60 * 60 * 24

gettimeofday( date, 0 );

}

Дизайн интерьера (http://balabukha.com/)
Таггу x_x
На сайте с 31.10.2005
Offline
445
#7
dkameleon:
В тему про даты, если кто ещё не видел:


Программистский шедевр на индусском форуме на тему "как узнать завтрашнюю дату" остался непревзойденным:

void get_tomorrow_date( struct timeval *date )
{
sleep( 86400 ); // 60 * 60 * 24
gettimeofday( date, 0 );
}

Черт, а красиво! :)

☠️☠️☠️
netUfo
На сайте с 09.02.2006
Offline
183
#8

А что такого... Люди может программированию обучаются. Каждый разными путями приходит к оптимизации кода.

сеотехнологии.рф (http://сеотехнологии.рф/)
pelvis
На сайте с 01.09.2005
Offline
345
#9

netUfo, когда эти люди снимают с заказчика тонну зелени - уже не смешно. А за ними весь сайт чистить приходится, так как дизайн не хотят переделывать, а верстки исходной нет.

Самое смешное, что так запрограммирован весь сайт. Он типа php, только весь код закоменчен. По 800 строк комента в каждой странице.

webcat
На сайте с 19.10.2005
Offline
137
#10
pelvis
Самое смешное, что так запрограммирован весь сайт. Он типа php, только весь код закоменчен. По 800 строк комента в каждой странице.

а чё. программист видно не ленивый - стучать по клаве сильно любит

:D :D 😂

12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий