更改以 d-M-Y 格式存储的日期的语言 php
Change language of the date stored in d-M-Y format php
我需要转换或更改我在 php
中回显的数据的语言
echo date('d-M-Y', strtotime($date));
这个回显例如 23-Jan-2017,而我想要它是西班牙语 23-Ene-2017。
你应该看到 the manual:
To format dates in other languages, you should use the setlocale()
and strftime()
functions instead of date()
.
setlocale(LC_TIME, 'es_ES');
echo strftime("%d-%h-%Y", strtotime($date));
这会给你想要的结果:
23-Ene-2017
请注意,为了显示西班牙语本地化,您必须安装西班牙语本地化。
实际上我在wordpress中使用这个所以我使用了date_i18n()
echo date_i18n('d-M-Y', strtotime( $date ));
我需要转换或更改我在 php
中回显的数据的语言echo date('d-M-Y', strtotime($date));
这个回显例如 23-Jan-2017,而我想要它是西班牙语 23-Ene-2017。
你应该看到 the manual:
To format dates in other languages, you should use the
setlocale()
andstrftime()
functions instead ofdate()
.
setlocale(LC_TIME, 'es_ES');
echo strftime("%d-%h-%Y", strtotime($date));
这会给你想要的结果:
23-Ene-2017
请注意,为了显示西班牙语本地化,您必须安装西班牙语本地化。
实际上我在wordpress中使用这个所以我使用了date_i18n()
echo date_i18n('d-M-Y', strtotime( $date ));