Welcome Guest, Not a member yet? Register   Sign In
format the date in model or view
#1

[eluser]searain[/eluser]
For example the date saved in database is '2010-01-29'.

model will retrieve this date value.

view will display this date value.

I want to display this date value as January 29th, 2010.

Which one is the better practice, should I format the date in view page or should I format it in model page right after I retrieve this date value?

I will think it is a view issue, so it should be in view page. model will just focus on retrive this date value from database. And in different view pages, we can format the date differently.

But at the same time, I would want to keep the view page less php codes for graphic designer to work with.

What is your advice?

Thanks!

-------

<b>On second thought, I think I was asking a silly question, it should be in view page to format the date.</b>
#2

[eluser]Colin Williams[/eluser]
This is exactly where helpers come in to play.




Theme © iAndrew 2016 - Forum software by © MyBB