yii2-usuario
yii2-usuario copied to clipboard
User admin list broken date
What steps will reproduce the problem?
At the users list the dates are not displayed properly
What is the expected result?
24 oct. 2017, 19:30:40
What do you get instead?
{0, data, MMMM dd, AAAA HH: mm}
Also for some reason it's taking 2-3 secs to load the page. I've made a quick fix and I've changed the date columns to use the Yii's date formatter:
[
'attribute' => 'last_login_at',
'format' => 'raw',
'value' => function ($model) {
return \Yii::$app->formatter->asDatetime($model->last_login_at);
},
],
I think that it's more better to use the Yii formatters because:
- they work
- don't have to put HTML code in classes
- page loads faster
- much less spaghetti
What language are you using for your app? are you sure you get data instead of date? What's the exact output string you get? Because I see it correctly in Italian:
About the output string I would agree in using Yii's formatting tools instead of writing custom formatting, I don't know why @tonydspaniard started using that notation... Anyway you could do even less code: there's no need to explicitly call formatter, you could leave the column as
'last_login_at:datetime',
But I'd rather open a new issue for this
oh, I forgot about the datetime format :grin:
I'm using english/hungarian/romanian languages but I didn't overwrite the view until today to fix this issue.
You mean even with english language you didn't see the date but the string above?
Yes
Unfortunately I cannot reproduce the issue. Can you give a try with 1.5-beta or latest master to see if it has been fixed? My guess (and hope) is this. Otherwise you must do some debugging yourself... Let me know
What do you think about refactoring this view to use the standard column formats for date, like: 'last_login_at:datetime'
. In the weekend I can make a PR if it's okay.
I think that it will improve the readability and solve this issue.
I have the same problem with 1.5-beta + also I have the same strange issue that the page load takes ~2 seconds longer if I use the original version instead of the last_login_at:datetime
version
I'm ok with using standard date and time formatting. If @tonydspaniard have nothing against it you can go (but I personally will not merge before aug 21st).
The long loading time is very curious, tough. Doesn't the yii2-debug toolbard help you in finding the culprit?
I haven't had time yet to investigate this issue, so I just replaced the column with datetime
.
After August 21 I will make a PR.
@maxxer @mrbig00 is this issue still valid?
Yes. For example here, why handling intl
presence? Isn't Yii doing it already? I'd replace these with just
created_at:datetime
so date display is handled by Yii. Also, if someone has custom date formatting it's taken into consideration, instead of doing a custom visualization in usuario.
If you have nothing against dropping intl
checks I'd make a patch with those changes
Thanks for your answer @maxxer
created_at:datetime
That would be the perfect solution!