Convert Date Format from MySQL Table [SOLVED]

Convert Date Format from MySQL Table [SOLVED]

ShadeShade Posts: 3Questions: 0Answers: 0
edited October 2012 in DataTables 1.9
Hi All,

I am very new at DataTables, and just recently installed it. I am using the server-side processing version of the script. Before this I was using TinyTable (found here: http://www.scriptiny.com/2009/11/advanced-javascript-table-sorter/). It was pretty simple to Convert Dates.
I would like to be able to do same with DataTables. Here's how I did it previously (using TinyTable):
[code]
$a=0;
while ($a < $num_rows){
/*leaving out some other code for simplicity sake*/
$complete_date_check = mysql_result($order_results, $a, "complete_date");
$convert_orderDate = strtotime($order_date);
$order_date = date('m-d-y', $convert_orderDate);
}
[/code]
Then all I would have to do is echo $order_date.
How would I implement something similar like this in DataTables? Should I just change the output array?

Thanks,

Replies

  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    edited October 2012
    Assuming you still want to do it using PHP / Server side - Just a function call / member function in a class would do - what ever you feel good for you

    [code]
    $date = 'yyyy/mm/dd'

    $date_array = explode('-', $date);
    $Y = $date_array[0];
    $M = $date_array[1];
    $D = $date_array[2];

    $formattedDate = $D."-".$M."-".$Y; // dd/mm/yyyy format
    [/code]

    Idea is to just rearrange the values of y/m/d to d/m/y
  • ShadeShade Posts: 3Questions: 0Answers: 0
    edited October 2012
    [SOVLED]
    Hi,

    I was actually able to figure it on my own. In the server_processing.php file, I added this to the output statement:
    [code]
    /*
    * Output
    */
    $output = array(
    "sEcho" => intval($_GET['sEcho']),
    "iTotalRecords" => $iTotal,
    "iTotalDisplayRecords" => $iFilteredTotal,
    "aaData" => array()
    );
    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
    $row = array();
    for ( $i=0 ; $i
This discussion has been closed.