Türkçe Tarih Formatlamak

PHP
22 lines
<?php
header('Content-Type: text/html; charset=utf-8');
class tr {
static function tarih($format='',$tarih=''){
$aylar = Array('Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık');
$gunler = Array('Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi');
if($tarih== ''){$tarih=time();}
$ftarih = str_replace('D','#1', $format);
$ftarih = str_replace('l','#2', $ftarih);
$ftarih = str_replace('M','#3', $ftarih);
$ftarih = str_replace('f','#4', $ftarih);
$gun = $gunler[date('w', $tarih)];
$ay = $aylar[date('m', $tarih)-1];
$cikti = str_replace('#1',$gun, date($ftarih, $tarih));
$cikti = str_replace('#2',$gun, $cikti);
$cikti = str_replace('#3',$ay, $cikti);
$cikti = str_replace('#4',$ay, $cikti);
return($cikti);
}
}
echo tr::tarih('d M Y, D H:i:s');
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Çıktısı

JavaScript
1 lines
23 Mayıs 2018, Çarşamba 20:38:10
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Metin İşleme ve Format Dönüştürme Sınıfı

PHP
22 lines
<?php
class metinDonustur {
var $_deger = '';
function metinDonustur($deger) {
$this->_deger = $deger;
}
function degerVer($deger) {
$this->_deger = $deger;
}
function degerAl() {
return $this->_deger;
}
function HTML() {
return htmlspecialchars($this->_deger);
}
}
$m=new metinDonustur("merhaba<br>");
echo $m->degerAl();
$m->degerVer("ulusan<br>");
echo $m->degerAl();
echo $m->HTML();
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Çıktısı

Markdown
3 lines
merhaba
ulusan
ulusan<br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX