3

如何以土耳其语显示日期?我正在尝试以下代码,但它根本不打印任何内容。

setlocale(LC_ALL, 'tr_TR.UTF-8');
echo strftime("%e %B %Y %A", time());
4

6 回答 6

8

虽然我不懂土耳其语,但它正在打印输出

  14 Şubat 2013 Perşembe

所以你的代码很好。希望你不会错过 php 标签。:/

于 2013-02-14T06:46:27.080 回答
2
<?php
            setlocale(LC_ALL, 'tr_TR.UTF-8');
            echo strftime("%e %B %Y %A", time());
          ?>

打印出来:30 Ekim 2015 Cuma

代码工作正常。

于 2015-10-30T21:00:26.180 回答
1

“F”的 PHP 日期,它给出英文名称的月份以翻译为土耳其语给定示例

date("d F")

你可以使用这个功能

   function convertMonthToTurkishCharacter($date){
    $aylar = array(
        'January'    =>    'Ocak',
        'February'    =>    'Şubat',
        'March'        =>    'Mart',
        'April'        =>    'Nisan',
        'May'        =>    'Mayıs',
        'June'        =>    'Haziran',
        'July'        =>    'Temmuz',
        'August'    =>    'Ağustos',
        'September'    =>    'Eylül',
        'October'    =>    'Ekim',
        'November'    =>    'Kasım',
        'December'    =>    'Aralık',
        'Monday'    =>    'Pazartesi',
        'Tuesday'    =>    'Salı',
        'Wednesday'    =>    'Çarşamba',
        'Thursday'    =>    'Perşembe',
        'Friday'    =>    'Cuma',
        'Saturday'    =>    'Cumartesi',
        'Sunday'    =>    'Pazar',
        'Jan' => 'Oca',
        'Feb' => 'Şub',
        'Mar' => 'Mar',
        'Apr' => 'Nis',
        'May' => 'May',
        'Jun' => 'Haz',
        'Jul' => 'Tem',
        'Aug' => 'Ağu',
        'Sep' => 'Eyl',
        'Oct' => 'Eki',
        'Nov' => 'Kas',
        'Dec' => 'Ara'

    );
    return  strtr($date, $aylar);
}
于 2020-03-07T11:08:14.370 回答
0
   public function getTurkishDate(){
       $locale = 'tr_TR'; // a canonicalized locale
       $format = 'dd-MMMM-YYYY'; // ISO format codes, not the typical date ones
       $dt = new DateTime(); // a DateTime object
       $df = new IntlDateFormatter(
           $locale, // string locale
           IntlDateFormatter::NONE, // int date type
           IntlDateFormatter::NONE, // int time type
           'UTC', // string timezone
           IntlDateFormatter::GREGORIAN, // int cal type
           $format // string pattern
       );
       return $df->format($dt); //string 07-Ağustos-2018
    } 

或者

    public function getTurkishDate(){
        $locale = 'tr_TR'; // a canonicalized locale
        $format = 'dd-MMMM-YYYY-EEEE'; // ISO format codes, not the typical date ones
        $dt = new DateTime(); // a DateTime object
        $df = new IntlDateFormatter(
            $locale, // string locale
            IntlDateFormatter::NONE, // int date type
            IntlDateFormatter::NONE, // int time type
            'UTC', // string timezone
            IntlDateFormatter::GREGORIAN, // int cal type
            $format // string pattern);
        return $df->format($dt); //string 07-Ağustos-2018-Salı
    } 

或者

    public function getTurkishDate(){
        $locale = 'tr_TR'; // a canonicalized locale
        $format = 'dd-MMMM-YYYY-ee'; // ISO format codes, not the typical date ones
        $dt = new DateTime(); // a DateTime object
        $df = new IntlDateFormatter(
            $locale, // string locale
            IntlDateFormatter::NONE, // int date type
            IntlDateFormatter::NONE, // int time type
            'UTC', // string timezone
            IntlDateFormatter::GREGORIAN, // int cal type
            $format // string pattern);
        return $df->format($dt); //string 07-Ağustos-2018-02
    } 
于 2018-08-07T08:13:04.270 回答
0

在代码之前添加它。

setlocale (LC_ALL, 'tr_TR.UTF-8', 'tr_TR', 'tr', 'turkish');
于 2018-04-01T01:07:10.133 回答
0

您可以通过以下方式获取当前日期和时间:

<?php
date_default_timezone_set("Europe/Istanbul");
//echo "The time is " . date("H:i") . "<br>";
//echo "Today is " . date("Y-m-d") . "<br>";
//echo "Today is " . date("l");
$now_time = date("H:i");
$now_date = date("Y-m-d");
?>
于 2019-04-18T20:31:39.187 回答