<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[KillerSites.com Web Design Forums - Change the date format Mysql - php]]></title>
		<link>http://www.killersites.com/forums/topic/2390/change-the-date-format-mysql-php/</link>
		<description><![CDATA[The most recent posts in Change the date format Mysql - php.]]></description>
		<lastBuildDate>Thu, 05 Nov 2009 13:16:21 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Change the date format Mysql - php]]></title>
			<link>http://www.killersites.com/forums/post/11929/#p11929</link>
			<description><![CDATA[<p>Finally, I found a solution:</p><p>I was trying to use the DATE_FORMAT function, but it didn&#039;t work (still don&#039;t know why)</p><p>I then changed this:</p><p>echo $row_RsEvents[&#039;column_date&#039;];</p><p>Into this:</p><p>$formatted_date= $row_RsEvents[&#039;column_date&#039;]; <br />echo date(&quot;d-m-Y&quot;,strtotime($formatted_date));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />and it works perfectly</p><p>Cheers, </p><p>Eduardo</p><br /><p>Edit:</p><p>Sorry Wickham, I didn&#039;t see your last edit. I am glad we both came to the same solution! (but yours is better than mine <img src="http://www.killersites.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" />)</p>]]></description>
			<author><![CDATA[dummy@example.com (edoplaza)]]></author>
			<pubDate>Thu, 05 Nov 2009 13:16:21 +0000</pubDate>
			<guid>http://www.killersites.com/forums/post/11929/#p11929</guid>
		</item>
		<item>
			<title><![CDATA[Re: Change the date format Mysql - php]]></title>
			<link>http://www.killersites.com/forums/post/11778/#p11778</link>
			<description><![CDATA[<p>Hi Wickham, </p><p>Thanks for your response. I haven&#039;t had the time to work today, but tomorrow I&#039;ll try what you suggest. I&#039;ll write a very simple code with just one record to isolate the problem and test different approaches. Also I bought a book with lots of information. I&#039;m sure this is a common issue, it shouldn&#039;t be that hard.</p><p>Edited:</p><p>Ok, I uploaded a very simple page with one record:</p><p><a href="http://www.germanmarcano.com/datetest.php" rel="nofollow">http://www.germanmarcano.com/datetest.php</a></p><p>Code:</p><div class="codebox"><pre><code>&lt;?php require_once(&#039;Connections/connAdmin.php&#039;); ?&gt;
&lt;?php
if (!function_exists(&quot;GetSQLValueString&quot;)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = &quot;&quot;, $theNotDefinedValue = &quot;&quot;) 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists(&quot;mysql_real_escape_string&quot;) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case &quot;text&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . $theValue . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;    
    case &quot;long&quot;:
    case &quot;int&quot;:
      $theValue = ($theValue != &quot;&quot;) ? intval($theValue) : &quot;NULL&quot;;
      break;
    case &quot;double&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . doubleval($theValue) . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;
    case &quot;date&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . $theValue . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;
    case &quot;defined&quot;:
      $theValue = ($theValue != &quot;&quot;) ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_connAdmin, $connAdmin);
$query_Rsprueba = &quot;SELECT * FROM eventos&quot;;
$Rsprueba = mysql_query($query_Rsprueba, $connAdmin) or die(mysql_error());
$row_Rsprueba = mysql_fetch_assoc($Rsprueba);
$totalRows_Rsprueba = mysql_num_rows($Rsprueba);
?&gt;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php echo $row_Rsprueba[&#039;fecha&#039;]; ?&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
mysql_free_result($Rsprueba);
?&gt;</code></pre></div><p>I will try to work on this file and see what happens</p><br /><p>Regards, </p><p>Eduardo</p>]]></description>
			<author><![CDATA[dummy@example.com (edoplaza)]]></author>
			<pubDate>Mon, 02 Nov 2009 00:26:48 +0000</pubDate>
			<guid>http://www.killersites.com/forums/post/11778/#p11778</guid>
		</item>
		<item>
			<title><![CDATA[Re: Change the date format Mysql - php]]></title>
			<link>http://www.killersites.com/forums/post/11773/#p11773</link>
			<description><![CDATA[<p>EDIT - go to my edit at the bottom of the post.</p><p>No one else has answered so I will offer a little more information, but my PHP and MySQL knowledge is not much; I was hoping falkencreative would answer the question properly.</p><p>Your page display has this code<br />&lt;td class=&quot;negrita&quot;&gt;Date:&lt;/td&gt;<br />&lt;td&gt;&lt;?php echo $row_RsEventos[&#039;fecha&#039;]; ?&gt;&lt;/td&gt;</p><p>which just repeats what is in the database field &#039;fecha&#039;, so perhaps one solution is to change the format in the database, not in the PHP code which displays it on the page.</p><p>If you look at this example:-<br /><a href="http://www.wickham43.net/formphptomysql.php" rel="nofollow">http://www.wickham43.net/formphptomysql.php</a></p><p>You will see a form for submission of data which has a date already inserted with a date format &lt;? echo date(&quot;d M Y&quot;); ?&gt; and the database stores this as text (Field: Date; Type: text) and the display of the data in the table at the bottom of the page just shows the text of the date that the database stored. You can see from the dates in the display that the format changes half way down because I changed the date format in the top submission form. </p><p>My Date is stored as text but you probably have the database storing date in a date format. You don&#039;t show how you get the dates into the database; either change the date format in the form you use to input into the database or go into the database and change the date format there. MySQL date is always stored in the YYYY-MM-DD format and it&#039;s complicated to reformat it so it may be easier to change the database Type to Text and then the PHP for the page should output the same text as the database.</p><p>Editing the Type for the Field in MySQL is relatively simple and you would then have to edit the previous database entries manually but future date entries as text would be repeated as text by the PHP code.</p><p>I expect that there is a way to take the date format from the database and change it to another format with PHP for the table display but falkencreative will have to answer that.</p><p>EDIT: I&#039;ve been experimenting and this code worked for me:-</p><p>date(&#039;d-m-Y&#039;, strtotime($row[&#039;fecha&#039;])) but I was testing with a different database and a different form</p><p>so where you have<br />&lt;td&gt;&lt;?php echo $row_RsEventos[&#039;fecha&#039;]; ?&gt;&lt;/td&gt;</p><p>in your PHP file I think you need</p><p>&lt;td&gt;&lt;?php echo date(&#039;d-m-Y&#039;, strtotime($row[&#039;fecha&#039;])); ?&gt;&lt;/td&gt;</p><p>Try it.</p>]]></description>
			<author><![CDATA[dummy@example.com (Wickham)]]></author>
			<pubDate>Sun, 01 Nov 2009 07:13:38 +0000</pubDate>
			<guid>http://www.killersites.com/forums/post/11773/#p11773</guid>
		</item>
		<item>
			<title><![CDATA[Re: Change the date format Mysql - php]]></title>
			<link>http://www.killersites.com/forums/post/11769/#p11769</link>
			<description><![CDATA[<p>All the date codes are here:-<br /><a href="http://php.net/manual/en/function.date.php" rel="nofollow">http://php.net/manual/en/function.date.php</a></p><p>Use d-m-Y for dd-mm-yyyy</p>]]></description>
			<author><![CDATA[dummy@example.com (Wickham)]]></author>
			<pubDate>Sat, 31 Oct 2009 21:34:38 +0000</pubDate>
			<guid>http://www.killersites.com/forums/post/11769/#p11769</guid>
		</item>
		<item>
			<title><![CDATA[Change the date format Mysql - php]]></title>
			<link>http://www.killersites.com/forums/post/11768/#p11768</link>
			<description><![CDATA[<p>Hello, </p><p>I&#039;d like to change the date format from my DB (yyyy-mm-dd) to dd-mm-yyyy using php.</p><p>Here is the url: </p><p>http://ww w.germanmarcano.com/eventos/indexEnglish.php</p><br /><p>Here is the code:</p><br /><br /><div class="codebox"><pre><code>&lt;?php require_once(&#039;../Connections/connAdmin.php&#039;); ?&gt;
&lt;?php
if (!function_exists(&quot;GetSQLValueString&quot;)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = &quot;&quot;, $theNotDefinedValue = &quot;&quot;) 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists(&quot;mysql_real_escape_string&quot;) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case &quot;text&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . $theValue . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;    
    case &quot;long&quot;:
    case &quot;int&quot;:
      $theValue = ($theValue != &quot;&quot;) ? intval($theValue) : &quot;NULL&quot;;
      break;
    case &quot;double&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . doubleval($theValue) . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;
    case &quot;date&quot;:
      $theValue = ($theValue != &quot;&quot;) ? &quot;&#039;&quot; . $theValue . &quot;&#039;&quot; : &quot;NULL&quot;;
      break;
    case &quot;defined&quot;:
      $theValue = ($theValue != &quot;&quot;) ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_RsEventos = 10;
$pageNum_RsEventos = 0;
if (isset($_GET[&#039;pageNum_RsEventos&#039;])) {
  $pageNum_RsEventos = $_GET[&#039;pageNum_RsEventos&#039;];
}
$startRow_RsEventos = $pageNum_RsEventos * $maxRows_RsEventos;

mysql_select_db($database_connAdmin, $connAdmin);
$query_RsEventos = &quot;SELECT * FROM eventos ORDER BY fecha DESC&quot;;
$query_limit_RsEventos = sprintf(&quot;%s LIMIT %d, %d&quot;, $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[&#039;totalRows_RsEventos&#039;])) {
  $totalRows_RsEventos = $_GET[&#039;totalRows_RsEventos&#039;];
} else {
  $all_RsEventos = mysql_query($query_RsEventos);
  $totalRows_RsEventos = mysql_num_rows($all_RsEventos);
}
$totalPages_RsEventos = ceil($totalRows_RsEventos/$maxRows_RsEventos)-1;
?&gt;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;!-- InstanceBegin template=&quot;/Templates/MainTemplateE.dwt.php&quot; codeOutsideHTMLIsLocked=&quot;false&quot; --&gt;
&lt;head&gt;

&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;/floatbox/floatbox.css&quot; /&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;/floatbox/floatbox.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#039;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#039; type=&#039;text/javascript&#039;%3E%3C/script%3E&quot;));
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-11331216-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;


&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;!-- InstanceBeginEditable name=&quot;doctitle&quot; --&gt;
&lt;title&gt;Events&lt;/title&gt;
&lt;!-- InstanceEndEditable --&gt;
&lt;link href=&quot;../css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;!-- InstanceBeginEditable name=&quot;head&quot; --&gt;&lt;!-- InstanceEndEditable --&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;div id=&quot;banner&quot;&gt;
    &lt;div id=&quot;bannercentered&quot;&gt;
         &lt;div id=&quot;mainNav&quot;&gt;
        
        &lt;ul class=&quot;mainMenu1&quot;&gt;
            
            &lt;li&gt;&lt;a href=&quot;../indexEnglish.php&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;../biografia/indexEnglish.php&quot;&gt;Biography&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href=&quot;../juicioscriticos/indexEnglish.php&quot;&gt;Critics&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
        &lt;ul class=&quot;mainMenu1&quot;&gt;
            
            
            &lt;li&gt;&lt;a href=&quot;../repertorio/indexEnglish.php&quot;&gt;Repertory&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;../grabaciones/indexEnglish.php&quot;&gt;CDs&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;../grabacionesvivo/indexEnglish.php&quot;&gt;Live Recordings&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
        
        &lt;ul class=&quot;mainMenu1&quot;&gt;
            
            
            &lt;li&gt;&lt;a href=&quot;../videos/indexEnglish.php&quot;&gt;Videos&lt;/a&gt;&lt;/li&gt;
             &lt;li&gt;&lt;a href=&quot;../publicaciones/indexEnglish.php&quot;&gt;Publications&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;../galeria/indexEnglish.php&quot;&gt;Gallery&lt;/a&gt;&lt;/li&gt;
          
         
        &lt;/ul&gt;
        
         &lt;ul class=&quot;mainMenu1&quot;&gt;
            
            
       
          &lt;li&gt;&lt;a href=&quot;indexEnglish.php&quot;&gt;Events&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;../contacto/indexEnglish.php&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
          
         
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;content&quot;&gt;&lt;!-- InstanceBeginEditable name=&quot;contenido&quot; --&gt;
  &lt;div id=&quot;contentcentered&quot;&gt;
   
   &lt;h1&gt;Events&lt;/h1&gt;
   
   &lt;?php do { ?&gt;
     &lt;div class=&quot;eventosind&quot;&gt;
       
       
       &lt;p class=&quot;tituloeventos&quot;&gt;&lt;?php echo $row_RsEventos[&#039;titulo&#039;]; ?&gt;&lt;/p&gt;
        
         
      
          
        &lt;table class=&quot;tablaeventosinicio&quot;&gt;
                   &lt;colgroup&gt;
                     &lt;col class=&quot;coleventos1&quot; /&gt;
                     &lt;col class=&quot;coleventos2&quot; /&gt;
                     &lt;/colgroup&gt;
                   &lt;tr&gt;
                     &lt;td class=&quot;negrita&quot;&gt;Date:&lt;/td&gt;
                        &lt;td&gt;&lt;?php echo $row_RsEventos[&#039;fecha&#039;]; ?&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                   &lt;tr&gt;
                     &lt;td class=&quot;negrita&quot;&gt;Place:&lt;/td&gt;
                        &lt;td&gt;&lt;?php echo $row_RsEventos[&#039;lugar&#039;]; ?&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                   &lt;tr&gt;
                     &lt;td class=&quot;negrita&quot;&gt;Time:&lt;/td&gt;
                        &lt;td&gt;&lt;?php echo $row_RsEventos[&#039;hora&#039;]; ?&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                 &lt;/table&gt;
                 &lt;p class=&quot;pequena&quot;&gt;&lt;?php echo $row_RsEventos[&#039;comentarios&#039;]; ?&gt;&lt;/p&gt;
     &lt;/div&gt;
     &lt;?php } while ($row_RsEventos = mysql_fetch_assoc($RsEventos)); ?&gt;&lt;/div&gt;
&lt;!-- InstanceEndEditable --&gt;&lt;/div&gt;

&lt;div id=&quot;footer&quot;&gt;
    &lt;div id=&quot;footercentered&quot;&gt;
    &lt;div id=&quot;copyright&quot;&gt;
    &lt;a href=&quot;../indexEnglish.php&quot;&gt;home&lt;/a&gt; | &lt;a href=&quot;../administracion/loginprincipal.php&quot;&gt;administration&lt;/a&gt; |  &lt;a href=&quot;../contacto/indexEnglish.php&quot;&gt;contact&lt;/a&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Copyright © Germán Marcano 2009&lt;br /&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!-- InstanceEnd --&gt;&lt;/html&gt;
&lt;?php
mysql_free_result($RsEventos);
?&gt;</code></pre></div><p>Thanks</p><br /><p>Eduardo</p>]]></description>
			<author><![CDATA[dummy@example.com (edoplaza)]]></author>
			<pubDate>Sat, 31 Oct 2009 19:32:30 +0000</pubDate>
			<guid>http://www.killersites.com/forums/post/11768/#p11768</guid>
		</item>
	</channel>
</rss>
