Welcome Guest, Not a member yet? Register   Sign In
Code Iginiter 4 + SQL Server + Date Formats in Models
#3

(This post was last modified: 03-17-2022, 09:26 AM by antidote.)

Thank you for the quick reply. Fair comment, if that's the ISO standard. It's my preferred format but in this particular case I inherited the db and it has other interfaces that already use the d-m-y format - in magnitude. In this rare case, I need to tell CI to perform the timestamp auto-saves with dates in the format d-m-y.

My impression was that constants are a better implementation option than assumed hardcoded values (even if they follow any particular standard) because there will always be exceptions. What is the harm in converting harcoded values to a single constant?

Of course, I have indeed set a human-readable mutator in the entity, which handles the display aspect of the date. However, again, this issue is more specifically that as there is no control over the delete_at date format, a model->save() fails when attempting to save data because the date format is in opposition to the date format of the database, and, given the database in this one rare case cannot be changed, what would my next option be if I wish to continue to keep it within the model? Forgive me if I am being stupid. 



(03-16-2022, 11:59 AM)iRedds Wrote: YYYY-MM-DD is the ISO 8601 date format.
The date format may differ from country to country, so the software uses ISO to store dates.
All DBMS support it. It is correctly read by both machine and human.

I would like to suggest that you use the ISO standard for the database. But to display the date to the user, convert it to the format used in your country.
If you are using an Entity, then it is easy to do this with a mutation (setter and getter)
Reply


Messages In This Thread
RE: Code Iginiter 4 + SQL Server + Date Formats in Models - by antidote - 03-17-2022, 08:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB