0

I am currently using date function to print out today's date. While doing this, I realized that the setlocale function does not work for Korean unfortunately so I am now wondering is there any way to directly translate from English to Korean through one to one mapping.

so currently I have

setlocale(LC_CTYPE, 'ko_KR,eucKR');
$today = date("Y년 m월 d일 l", strtotime('today'));

This prints 2014년 9월 12일 Monday and I would like to change Monday to 월.

So instead of relying on setlocale I want to know if it is possible to directly change this like:

Monday => 월 etc.
4

3 回答 3

1

Setlocale返回已设置的本地标识符(“新当前语言环境”)。检查它返回给您的内容。

稍后,您可以检查系统中是否安装了所需的语言环境。GNU/Linux 示例:

$ locale -a
于 2014-09-12T04:31:36.290 回答
0

我猜你没有在运行脚本的系统上安装韩语语言环境。您仍然可以在格式化日期的末尾附加当天的正确单词。

<?php

$days = array(
         '일',
         '월',
         '화',
         '수',
         '목',
         '금',
         '토'
        );

$today = date("Y년 m월 d일 w", strtotime('today'));
$today = substr_replace($today, $days[substr($today, -1)], -1);

echo $today;

输出(在撰写本文时):

2014년 09월 12일 금
                 ^ friday
于 2014-09-12T04:27:59.880 回答
0

date('w') 返回一个数字,表示从 0(星期日)到 6(星期六)的一周中的每一天。

您可以创建一个数组:

<?php 
$kor_day = array( '일', '월', '화', '수', '목', '금', '토' );
echo $kor_day[date('w')];
?>

它将以韩文输出星期几。

于 2017-11-14T09:51:17.173 回答