Format Date
Format Date
aswebtechnology
Posts: 19Questions: 0Answers: 0
Hi,
I am having a datetime column in my mysql table.
In datatable the date is showing as 2012-05-12 21:54:24. But I want to display it as May 12, 2012 21:54:24.
How can I do this? Anybody if knows, please help me in achieving this.
Thanks in advance.
I am having a datetime column in my mysql table.
In datatable the date is showing as 2012-05-12 21:54:24. But I want to display it as May 12, 2012 21:54:24.
How can I do this? Anybody if knows, please help me in achieving this.
Thanks in advance.
This discussion has been closed.
Replies
[code]
if ( $aColumns[$i] == "version" ) {
/* Special output formatting for 'version' column */
$row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : $aRow[ $aColumns[$i] ];
}
[/code]
So something like...
[code]
if ( $aColumns[$i] == "your_date_field" ) {
/* Special output formatting for 'your_date_field' column */
$date = strtotime($aRow[$i]);
$format_date = date('d-m-Y', $date);
$row[] = $format_date;
} else if ( $aColumns[$i] != ' ' ) {
/* General output */
...
...
}
[/code]
Note: your_date_field above will be the same field name you have specified in the:
[code]
$aColumns = array( '...', '...', 'your_date_field', '...');
[/code] (near the top of your page)
Then checking the examples here (http://php.net/manual/en/function.date.php) and changing 'd-m-Y' in the date() function above will let you get the exact format you want the date to be in.
Have a look at "Example #4 date() Formatting" it should have the date format you want.