Machuss Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) $ned_diena = date("w"); if ($ned_diena == 1) { echo "Primdiena "; } if ($ned_diena == 2) { echo "Otrdiena "; } if ($ned_diena == 3) { echo "Trešdiena "; } if ($ned_diena == 4) { echo "Ceturtdiena "; } if ($ned_diena == 5) { echo "Piektdiena "; } if ($ned_diena == 6) { echo "Sestdiena "; } if ($ned_diena == 0) { echo "Svētdiena "; } Es izmantoju šādu kodu, bet kā es varu definēt funkciju, kādā veidā neizmantojot DB es varētu iegūt mainiigo $dienasdatums lai būtu vienkāršād nedēļas dienu iekļaut tekstā. Ja ir iespējams es gribētu noskaidrot kā var iegūt šī koda rezūltātu kā $dienasdatums . Ceru ka neizteicos pārāk neskaidri. Edited March 16, 2006 by Machuss Link to comment Share on other sites More sharing options...
bubu Posted March 16, 2006 Report Share Posted March 16, 2006 Šādi vai? function getNedDiena($nr) { static $dienas = array("Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena"); return $dienas[$nr]; } echo getNedDiena(date("w")); Link to comment Share on other sites More sharing options...
Blitz Posted March 16, 2006 Report Share Posted March 16, 2006 (edited) function dien_nos($dien) { switch ($dien) { case 1: $diena="Pirmdiena"; break; case 2: $diena="Otridiena"; break; case 3: $diena="Tresdiena"; break; case 4: $diena="Ceturtdiena"; break; case 5: $diena="piekdiena"; break; case 6: $diena="Sestdiena"; break; case 7: $diena="Svetdiena"; break; default: $diena="error"; break; } return $diena; } $ned_diena=date("w"); $dienasdatums=dien_nos($ned_diena); kautkaa taa, ja pareizi tevi sapratu... + bubu pasteidzaas.... Edited March 16, 2006 by Blitz Link to comment Share on other sites More sharing options...
v3rb0 Posted March 16, 2006 Report Share Posted March 16, 2006 http://lv.php.net/setlocale un tur pat piemērs <? setlocale(LC_ALL, 'lv_LV'); echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978)); ?> Link to comment Share on other sites More sharing options...
Machuss Posted March 16, 2006 Author Report Share Posted March 16, 2006 Man definētās funkcijas nestrādā, vai vinjas kaadaa failaa veel buutu jaapiefiksee? Jo kad palaizhu man raadaas balta lapa. Link to comment Share on other sites More sharing options...
Blitz Posted March 16, 2006 Report Share Posted March 16, 2006 pirmamkaartam vinu vajag izsaukt.... Link to comment Share on other sites More sharing options...
v3rb0 Posted March 16, 2006 Report Share Posted March 16, 2006 Blitz: otrāmkārtām date("w") atgriež 0 (for Sunday) through 6 (for Saturday) Link to comment Share on other sites More sharing options...
Blitz Posted March 16, 2006 Report Share Posted March 16, 2006 ups piemirsu... enivej manaa gadijumaa tam vajadzetu izsaukt error Link to comment Share on other sites More sharing options...
Machuss Posted March 16, 2006 Author Report Share Posted March 16, 2006 Blitz skripts man straadaa, paldies .. bet Bubu skriptu es veel neizpratu. Link to comment Share on other sites More sharing options...
Blitz Posted March 16, 2006 Report Share Posted March 16, 2006 bubu variantaa izskatas ka tev $ned_diena janomaina pret $nr Link to comment Share on other sites More sharing options...
bubu Posted March 16, 2006 Report Share Posted March 16, 2006 Ui sorr, kļūda. Tagad izlaboju. Tā ir ka ar copy&paste nodarbojas. Link to comment Share on other sites More sharing options...
Recommended Posts