hisham
IS-IT--Management
- Nov 6, 2000
- 194
I found the following function to display the date i.e. 13 Jul 2002
The formatDate() function in the code above is a function wrote to turn a MySQL timestamp into a human-friendly date string:
functions.php:
--------------------------------------
function formatDate($val)
{
$arr = explode("-", $val);
return date("d M Y", mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
}
--------------------------------------
display.php:
--------------------------------------
// includes
include("../functions.php"
// generate and execute query
$query = "SELECT field1, field2, timestamp FROM tablename ORDER BY timestamp DESC LIMIT 0, 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_object($result))
{
?>
<br>
<font size="-2"><? echo formatDate($row->timestamp); ?></font>
<p>
--------------------------------------------
This display date in English, how to display it in other languages like Spanish?
The formatDate() function in the code above is a function wrote to turn a MySQL timestamp into a human-friendly date string:
functions.php:
--------------------------------------
function formatDate($val)
{
$arr = explode("-", $val);
return date("d M Y", mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
}
--------------------------------------
display.php:
--------------------------------------
// includes
include("../functions.php"
// generate and execute query
$query = "SELECT field1, field2, timestamp FROM tablename ORDER BY timestamp DESC LIMIT 0, 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_object($result))
{
?>
<br>
<font size="-2"><? echo formatDate($row->timestamp); ?></font>
<p>
--------------------------------------------
This display date in English, how to display it in other languages like Spanish?