| px | top | add code | search | signup | login | help |
<?php
function turkish_date($parameter) {
/* Start of function | Fonksiyonun başlangıcı */
/* function turkish_date
*
* Berk Demir <berk@linux.org.tr>
* bdd - 2000
*
* English : Function that returns a string, includes,
* Turkish Date format with char. type months and weekday names.
*
* How to use ? :
* Include the funtion code into your php source code. Call the function
* and get its return value to a variable.
*
* Example :
* $turkishdate = turkish_date();
*
* The content of the $turkishdate will be "8 Nisan 2000, Cumartesi" in
* example...
*
* Passing parameters :
* If you just need the month or weekday, or day or year...
* Function can return you just the part you want. To do this, you must pass
* a parameter to the function.
*
* How ? :
* $value=turkish_date("hg"); will return just the weekday name.
*
* Other avaliable paramaters are :
* "a" -> Name of the month
* "g" -> day
* "y" -> year
*
* If you don't pass any parameter, you'll get the full date. Like in the * * example above.
*
* -------------------------------------------------------------------------
*
* Türkçe : Ay ve haftanın gününün yazı ile yazıldığı tarih formatını içeren
* bir string'i döndüren fonksiyon.
*
* Örnek Çıktı : 8 Nisan 2000, Cumartesi
*
* Nasıl Kullanılır ? :
* Yazdığınız kod içine fonksiyonu dahil ediniz ve kod içinde çıktıyı başka
* bir değişkene atamak için :
*
* $tarih = turkish_date();
*
* yazabilirsiniz. Artık $tarih değişkeni istenilen formatta tarihi
* içermektedir.
*
* Parametre gecirmek :
* Eğer sadece hafatnın gününü veya ay ismmin veya günü veya yılı almak
* isterseniz fonksiyonuna parametre geçirmeniz gerekecektir.
*
* Nasıl ?:
* $value=turkish_date("hg"); Bu sekilde cagirilirsa, sadece haftanin gunu
* dönecektir.
*
* Diğer parametreler:
* "a" -> Ay ismi
* "g" -> Gün
* "y" -> Yıl (4 haneli)
*/
$weekdays[0] = "Pazar";
$weekdays[1] = "Pazartesi";
$weekdays[2] = "Salı";
$weekdays[3] = "Çarşamba";
$weekdays[4] = "Perşembe";
$weekdays[5] = "Cuma";
$weekdays[6] = "Cumartesi";
$months[1] = "Ocak";
$months[2] = "Şubat";
$months[3] = "Mart";
$months[4] = "Nisan";
$months[5] = "Mayıs";
$months[6] = "Haziran";
$months[7] = "Temmuz";
$months[8] = "Ağustos";
$months[9] = "Eylül";
$months[10] = "Ekim";
$months[11] = "Kasım";
$months[12] = "Aralık";
$haftagunu = date( "w");
$ay = date( "m");
$yil = date("Y");
$gun = date("d");
/* Ay degiskeni iki halneli deldiginden dolayi,
* 10 dan kucuk olanlari kontrol ediyoruz.
*/
if($ay < 10)
$ay_n=substr($ay,1,1);
else
$ay_n=$ay;
switch($parameter) {
case "hg":
$output = $weekdays[$haftagunu];
break;
case "g":
$output = $gun;
break;
case "a":
$output = $ay_n;
break;
case "y":
$output = $yil;
break;
default:
$output=($gun. " ".$months[$ay_n]. " ".$yil. ", ".$weekdays[$haftagunu]);
break;
} /* End of switch | switch 'in sonu */
return $output;
} /* End of Function | Fonksiyonun sonu */
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.