Topic: Change the date format Mysql - php
Hello,
I'd like to change the date format from my DB (yyyy-mm-dd) to dd-mm-yyyy using php.
Here is the url:
http://ww w.germanmarcano.com/eventos/indexEnglish.php
Here is the code:
<?php require_once('../Connections/connAdmin.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_RsEventos = 10;
$pageNum_RsEventos = 0;
if (isset($_GET['pageNum_RsEventos'])) {
$pageNum_RsEventos = $_GET['pageNum_RsEventos'];
}
$startRow_RsEventos = $pageNum_RsEventos * $maxRows_RsEventos;
mysql_select_db($database_connAdmin, $connAdmin);
$query_RsEventos = "SELECT * FROM eventos ORDER BY fecha DESC";
$query_limit_RsEventos = sprintf("%s LIMIT %d, %d", $query_RsEventos, $startRow_RsEventos, $maxRows_RsEventos);
$RsEventos = mysql_query($query_limit_RsEventos, $connAdmin) or die(mysql_error());
$row_RsEventos = mysql_fetch_assoc($RsEventos);
if (isset($_GET['totalRows_RsEventos'])) {
$totalRows_RsEventos = $_GET['totalRows_RsEventos'];
} else {
$all_RsEventos = mysql_query($query_RsEventos);
$totalRows_RsEventos = mysql_num_rows($all_RsEventos);
}
$totalPages_RsEventos = ceil($totalRows_RsEventos/$maxRows_RsEventos)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/MainTemplateE.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<link type="text/css" rel="stylesheet" href="/floatbox/floatbox.css" />
<script type="text/javascript" src="/floatbox/floatbox.js"></script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11331216-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Events</title>
<!-- InstanceEndEditable -->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body>
<div id="banner">
<div id="bannercentered">
<div id="mainNav">
<ul class="mainMenu1">
<li><a href="../indexEnglish.php">Home</a></li>
<li><a href="../biografia/indexEnglish.php">Biography</a></li>
<li><a href="../juicioscriticos/indexEnglish.php">Critics</a></li>
</ul>
<ul class="mainMenu1">
<li><a href="../repertorio/indexEnglish.php">Repertory</a></li>
<li><a href="../grabaciones/indexEnglish.php">CDs</a></li>
<li><a href="../grabacionesvivo/indexEnglish.php">Live Recordings</a></li>
</ul>
<ul class="mainMenu1">
<li><a href="../videos/indexEnglish.php">Videos</a></li>
<li><a href="../publicaciones/indexEnglish.php">Publications</a></li>
<li><a href="../galeria/indexEnglish.php">Gallery</a></li>
</ul>
<ul class="mainMenu1">
<li><a href="indexEnglish.php">Events</a></li>
<li><a href="../contacto/indexEnglish.php">Contact</a></li>
</ul>
</div>
</div>
</div>
<div id="content"><!-- InstanceBeginEditable name="contenido" -->
<div id="contentcentered">
<h1>Events</h1>
<?php do { ?>
<div class="eventosind">
<p class="tituloeventos"><?php echo $row_RsEventos['titulo']; ?></p>
<table class="tablaeventosinicio">
<colgroup>
<col class="coleventos1" />
<col class="coleventos2" />
</colgroup>
<tr>
<td class="negrita">Date:</td>
<td><?php echo $row_RsEventos['fecha']; ?></td>
</tr>
<tr>
<td class="negrita">Place:</td>
<td><?php echo $row_RsEventos['lugar']; ?></td>
</tr>
<tr>
<td class="negrita">Time:</td>
<td><?php echo $row_RsEventos['hora']; ?></td>
</tr>
</table>
<p class="pequena"><?php echo $row_RsEventos['comentarios']; ?></p>
</div>
<?php } while ($row_RsEventos = mysql_fetch_assoc($RsEventos)); ?></div>
<!-- InstanceEndEditable --></div>
<div id="footer">
<div id="footercentered">
<div id="copyright">
<a href="../indexEnglish.php">home</a> | <a href="../administracion/loginprincipal.php">administration</a> | <a href="../contacto/indexEnglish.php">contact</a> Copyright © Germán Marcano 2009<br />
</div>
</div>
</div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($RsEventos);
?>Thanks
Eduardo
Last edited by edoplaza (2009-10-31 14:33:17)
