1

I want to turning the name of month into Turkish Language (like April = Nisan). I defined a function for this. It's working but Turkish month name is not look right. I think there are a Turkish language character problem. How can i fix this problem? screen shot

My date translate function:

function tarih_formatla_unix($format,$ftarih,$kacgun) //tarih_formatla_unix("GG Ay YYYY",$date,0)
{ 
  $ftarih = date('d.m.Y', strtotime($ftarih));
  $bolisaret = ".";
  $tarih = explode("$bolisaret",$ftarih);
  $gun = $tarih[0];
  $ay = $tarih[1];
  $yil = $tarih[2];
  $ftarih = mktime(0, 0, 0, $ay, ($gun+$kacgun), $yil);
  $gun = date("d",$ftarih);
  $ay  = date("n",$ftarih) - 1; //-1 dizi 0'dan başladığı için
  $yil = date("Y",$ftarih);

  $turkay = array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");
  $enay = array("January","February","March","April","May","June","July","August","September","October","November","December");
  $turkgun = array("Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi","Pazar");
  $engun = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");

  if ($format == "GG Ay") $TAMTARIH = $gun . " " . $turkay[$ay];
  if ($format == "GG Ay YYYY") $TAMTARIH = $gun . " " . $turkay[$ay] . " " . $yil;
  return $TAMTARIH;
}
Ayhan Kesicioglu
  • 460
  • 5
  • 10

1 Answers1

0

There is 1 remark regarding your code and another answer which will help you with all the settings needed to be done when using UTF-8 characters.

The remark is that you can use the setlocale and strftime functions instead of using that custom function you've done.

setlocale(LC_TIME, 'tr_TR');
var_dump(strftime('%A %d %m %Y'));

More information about how to use UTF-8 encoding can be found by following this question: UTF-8 - All the way through

Community
  • 1
  • 1
Mihai Matei
  • 24,166
  • 5
  • 32
  • 50
  • 1
    Thanks. I found where I made mistakes. I have saved this php file in **Ansi**. I saved this page **UTF8 Without BOM** and the month name looks correct. – Ayhan Kesicioglu Nov 03 '16 at 09:08