note 94399 added to function.strftime
| From: | szilagyigabor at yahoo dot com | Date: | Mon, 02 Nov 2009 19:43:51 +0000 |
| Subject: | note 94399 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162342@lists.php.net to get a copy of this message | ||
This is that worked with UTF-8 encoding on Linux server, with right accents:
<?php
setlocale(LC_ALL, 'hu_HU.UTF8');
echo(strftime('%Y. %B %d. %A'));
?>
Output is:
2009. november 02. hétfÅ
Also, this one can be used, if not utf-8 preferred:
<?php
setlocale(LC_ALL, 'hu_HU.ISO8859-2');
?>
UTF-8 is not supported on windows platforms, so there the iconv workaround must be used:
<?php
setlocale(LC_ALL, 'hun_hun');
echo(iconv('ISO-8859-2', 'UTF-8',strftime('%Y. %B %d. %A')));
?>
The output is the same as before. Note that, the iconv first parameter is ISO-8859-2 not ISO-8859-1,
because the locale is hungarian which uses 8859-2 codepage as default. It is needed for the right
accents.
If you want use the same code for Windows and Linux platforms, the second one is the right option
(the iconv trick), but the locale configuration must be different (Linux: hu_HU, windows: hun_hun),
but in that case the UTF8 tag is not needed for the Linux config.
----
Server IP: 69.147.83.197
Probable Submitter: 86.101.80.73
----
Manual Page -- http://www.php.net/manual/en/function.strftime.php
Edit -- https://master.php.net/note/edit/94399
Del: integrated -- https://master.php.net/note/delete/94399/integrated
Del: useless -- https://master.php.net/note/delete/94399/useless
Del: bad code -- https://master.php.net/note/delete/94399/bad+code
Del: spam -- https://master.php.net/note/delete/94399/spam
Del: non-english -- https://master.php.net/note/delete/94399/non-english
Del: in docs -- https://master.php.net/note/delete/94399/in+docs
Del: other reasons-- https://master.php.net/note/delete/94399
Reject -- https://master.php.net/note/reject/94399
Search -- https://master.php.net/manage/user-notes.php