Formatting mysql date in column

Formatting mysql date in column

James PayneJames Payne Posts: 15Questions: 0Answers: 0
edited February 2011 in General
Hello,

how can I format a date column I have that lists mysql dates from my database? I'm using server-side processing to get the details from my db.

I would like to turn 2010-04-27 into 27th April 2010.

So far I have...

[code]"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 2 ] },
{ "fnRender": function ( oObj ) {
return oObj.aData[4];
},
"aTargets": [ 4 ]
}

],[/code]

...but I'm not sure what function I need to do this.

Can anyone help?

Thanks

Replies

  • GerardoGerardo Posts: 66Questions: 0Answers: 0
    I use UNIX_TIMESTAMP(when), then

    var dWhen = new Date(1000 * oObj.aData[oObj.iDataColumn]);
    return dWhen.toLocaleTimeString()

    or whatever function to print a date in the format you want.

    Hth,
    Gerardo
  • tehgreedotehgreedo Posts: 7Questions: 0Answers: 0
    If you want it formatted in the query...
    [code]
    $aColumns = array( 'DATE_FORMAT(date_in,"%Y-%m-%d")', 'url', 'notes', 'user');
    [/code]
This discussion has been closed.