|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76123 Implement Month Genitive and Nominative Names in date format functions
Submitted: 2018-03-21 07:51 UTC Modified: 2018-03-21 08:18 UTC
From: murznn at gmail dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: Next Major Version OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: murznn at gmail dot com
New email:
PHP Version: OS:


 [2018-03-21 07:51 UTC] murznn at gmail dot com
Some languages have 2 cases of month names - genitive and nominative. Eg in Russian - January have 2 cases - 'Январь' and 'января', depended on month place in string.

'1 January' in Russian must be translated as '1 января'
'January, 1' in Russian must be translated as 'Январь, 1'

But PHP date function have only one case for month name - 'F', that translates to nominative case, and there are no way to translate in genitive case.

There are many workarounds for this problem via custom scripts, also this already implemented in some systems, eq in Russian PHP CMS Bitrix: added 'f' symbol that return month in genitive case.

On some other languages, eg C# - this feature is implemented:

Because function date() not use locale, my suggestion is to add new symbol to PHP strtotime() and DateTime::format functions, that will return month name in genitive case with no capital letter. For example, this can be '%L' symbol, that return localized month name in genitive case.

Or maybe community can provide some better solutions for this problem in PHP core.

P.S. Description of problem in Russian language: Правильное склонение месяца в датах через PHP функции strtotime() и DateTime::format в именительном и родительном падежах на русском языке.

Test script:
setlocale(LC_TIME, 'ru_RU.UTF-8');
echo strftime('%B %L', strtotime('2000-01-01'));

Expected result:
Январь января

Actual result:
Январь %L


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-21 08:18 UTC]
-Status: Open +Status: Wont fix
 [2018-03-21 08:18 UTC]
strftime() is not a function that PHP created. It's actually defined in C,
and PHP's strftime() is just a thin "wrapper" around it. So we can't really change that.

PHP does have date() formatting, but what you're asking for is too complex for us to manage.

The good news is that what you need exists as part of the intl extension. Example:

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jan 30 08:05:52 2023 UTC