07-07-2009, 01:37 PM
|
#2 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
PHP Code:
<?php
function formatdate( $s )
{
return date( "d-m-Y", strtotime( $s ) );
}
// how to use this function
echo formatdate( $result[ "DateUpdated" ] );
?>
strtotime converts arbitrary strings to date and time value that can be used with other date related functions. date function formats a given date and time value back to a string.
This query will help:
PHP Code:
$query = "SELECT *, DATE_FORMAT( DateUpdated, '%d-%m-%Y' ) AS FormattedDate FROM CharacterStats ORDER BY ID ASC";
The above query returns one additional column called FormattedDate that contains the DateUpdated in the desired format.
http://php.net/strtotime
http://php.net/manual/en/function.date.php
|
|
|
|