Render in the js or format in the php?

Render in the js or format in the php?

mihomesmihomes Posts: 165Questions: 23Answers: 0
edited February 2014 in General
Just wondering what the preference is for other people and the pros / cons of either. For instance, when using serverside on a timestamp column... you can format the value in php and return a nice date/time display OR you can do the same in js with render. Is there a performance gain of either? I an leaning towards rendering values as I think that keeps the original db value intact should it be used elsewhere for operations.

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    It really depends upon each situation - I use both and switch between them as the situation demands. Often the decision is simply "most of my logic is in X, so I'll put the rendering there as well".

    Allan
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    There's another option (my own preference) - let the database do the work of formatting the date. Although of course that only applies if you have only one (display) use for the date.
  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    Yeah. I am using the php to do quite a few things already with the format return. I guess my logic was partly due to liking php better than js. The question popped in my head though and it got me wondering. The only thing I thought was by using render on the js side of things you would always have the ability to grab the original value from a column whereas using php on the server it is 'given' to datatables in the new format.
This discussion has been closed.