I have a page where first 10 news are displayed serverside (coldfusion), while next set of 10 is loaded on click (ajax, jquery). now, while everything works like a charm serverside, on client i am having issue formatting and displaying date. More specifically, there is one method that loads data (returns query result) and helper component that formats date (sort of) to be shown like this (a few moments ago, 5 hours ago etc). In CF i call function that handles formatting straight from cfoutput. this works flawlessly hence there is no need to post the entire code that mathematically counts range.
<cfset loadNews = sql.Getnews(orderBy="Date",startFrom=0)>
<cfset helper = createObject ("component","cfc.helper")>
<cfoutput query="loadNews">
#helper.formatDate(nDate=Date)#
</cfoutput>
on the other hand, json returns date like this September, 29 2013 15:05:45 and in some cases, when local language is changed I can not format date properly and do the same math with javascript(jquery). what's the best, most functional way to get the same functionality on client? should I use query of queries perhaps to convert datetime to string value using the same function and return the result or somehow do everything on client. I would really appreciate your help on this one :(
and yes date in mysql table (datetime column) looks like this 2013-09-30 17:24:56
here is the solution
<cfset newColumn = ArrayNew(1)>
<cfloop query="qNews">
<cfset arrayAppend(newColumn, helper.formatDate(nDate=qNews.Date))>
</cfloop>
<cfset queryAddColumn(qNews, "fDate", newColumn)>