Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dateFormat: 'php:' do not work correct #37

Open
ComradePashka opened this issue May 2, 2016 · 2 comments
Open

dateFormat: 'php:' do not work correct #37

ComradePashka opened this issue May 2, 2016 · 2 comments
Assignees
Labels
type:docs Documentation
Milestone

Comments

@ComradePashka
Copy link

With simple config

// config:
'formatter' => [
  'class' => 'yii\i18n\Formatter',
//  'dateFormat' => 'php:d-M-Y',
  'dateFormat' => 'dd.MM.yyyy',
],

// model rules():
['published_at', 'date', 'timestampAttribute' => 'published_at'],

// widget:
$form->field($model, 'published_at')->widget(DatePicker::className(), [
  'options' => ['class' => 'form-control'],
])

everything works ok, but if 'dateFormat' of formatter will be changed to, for example 'php:d-M-Y' datePicker widget starts handle different with DateValidator formatting, so posted value will never pass validation.

if alternately set up 'format' for model rule and same format as 'dataFormat' for DatePicker widget to avoid using global formatter values, anyways it will handle format 'php:d-M-Y' incorrectly. Client script looks like:

  $('#post-published_at').datepicker($.extend({}, $.datepicker.regional['ru'], {"dateFormat":"dd-M-yy"}));

and when form with existent data loads, then data shown (for russian locale) as "19-мая-2016" but when I changed date - it shown as "18-Май-2016". so it has different form of nouns for month and obviously format is not same.

I am not sure it is real bug, but looks like some date format won't be handled correctly as described.

Additional info

component version
Yii vesion 2.0.8
PHP version 7.0.4
Operating system Ubuntu xenial
@cebe
Copy link
Member

cebe commented May 3, 2016

PHP can not handle international date format. you have to use the intl format for that.

@cebe cebe closed this as completed May 3, 2016
@ComradePashka
Copy link
Author

ah. ok, maybe it is good idea to make small reminding note about it in documentation?

@cebe cebe reopened this May 5, 2016
@cebe cebe self-assigned this May 5, 2016
@cebe cebe added this to the 2.0.6 milestone May 5, 2016
@cebe cebe added the type:docs Documentation label May 5, 2016
@samdark samdark modified the milestones: 2.0.6, 2.0.7 Jul 22, 2016
@samdark samdark modified the milestones: 2.0.7, 2.0.8 Nov 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Documentation
Projects
None yet
Development

No branches or pull requests

3 participants