<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How do I make my MySQL table automatically make a timestamp when new data is added?</title>
	<atom:link href="http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/</link>
	<description>Solving everyday practical LAMP problems... one at a time</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:54:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: nore h</title>
		<link>http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/comment-page-1/#comment-1273</link>
		<dc:creator>nore h</dc:creator>
		<pubDate>Fri, 19 Feb 2010 17:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/#comment-1273</guid>
		<description>&lt;?php
if (!isset($_POST[&#039;submit&#039;])) {
?&gt;
&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
Table Name:  &lt;input type=&quot;text&quot; size=&quot;40&quot; maxlength=&quot;90&quot; name=&quot;table&quot;&gt;&lt;br&gt;
Column 1: &lt;input type=&quot;text&quot; size=&quot;40&quot; maxlength=&quot;90&quot; name=&quot;col1&quot;&gt;&lt;br&gt;
Column 2: &lt;input type=&quot;text&quot; size=&quot;40&quot; maxlength=&quot;90&quot; name=&quot;col2&quot;&gt;&lt;br&gt;
Column 3: &lt;input type=&quot;text&quot; size=&quot;40&quot; maxlength=&quot;90&quot; name=&quot;col3&quot;&gt;&lt;br&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Create Table!&quot;&gt;
&lt;/form&gt;
&lt;?php
} else {
$table = $_POST[&#039;table&#039;];
$col1 = $_POST[&#039;col1&#039;];
$col2 = $_POST[&#039;col2&#039;];
$col3 = $_POST[&#039;col3&#039;];
mysql_query(&quot;CREATE TABLE $table(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
$col1 VARCHAR(50),
$col2 VARCHAR(90),
$col3 VARCHAR(200))&quot;)
or die(mysql_error());

echo &quot;Success! Your table &quot;$table&quot; has been created!&quot;;

}
?&gt;</description>
		<content:encoded><![CDATA[<p>< ?php<br />
if (!isset($_POST['submit'])) {<br />
?></p>
<form action="" method="post">
Table Name:<br />
<input type="text" size="40" maxlength="90" name="table"/>
Column 1:<br />
<input type="text" size="40" maxlength="90" name="col1"/>
Column 2:<br />
<input type="text" size="40" maxlength="90" name="col2"/>
Column 3:<br />
<input type="text" size="40" maxlength="90" name="col3"/></p>
<input type="submit" name="submit" value="Create Table!"/>
</form>
<p>< ?php<br />
} else {<br />
$table = $_POST['table'];<br />
$col1 = $_POST['col1'];<br />
$col2 = $_POST['col2'];<br />
$col3 = $_POST['col3'];<br />
mysql_query("CREATE TABLE $table(<br />
id INT NOT NULL AUTO_INCREMENT,<br />
PRIMARY KEY(id),<br />
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,<br />
$col1 VARCHAR(50),<br />
$col2 VARCHAR(90),<br />
$col3 VARCHAR(200))")<br />
or die(mysql_error());</p>
<p>echo "Success! Your table "$table" has been created!";</p>
<p>}<br />
?></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: just "JR"</title>
		<link>http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/comment-page-1/#comment-1272</link>
		<dc:creator>just "JR"</dc:creator>
		<pubDate>Fri, 19 Feb 2010 17:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/#comment-1272</guid>
		<description>First, don&#039;t use &quot;timestamp&quot;: that is UNIX time stamp: the number of seconds since January 1 1970 00:00:00 GMT

Set the column variable as &quot;datetime&quot; type with the default value 0000-00-00 00:00:00 (for a format YYYY:MM:DD HH:MM:SS), and call this column &quot;datum&quot; (don&#039;t use &quot;date&quot;, &quot;datetime&quot; or &quot;timestamp&quot;!: reserved words)
Advantage of this format: easy sorting!

When inserting, use:
$datum = date ( &quot;Y-m-d H:i:s&quot;);
This will get current time and date, correctly formatted.
Your sql:
$sql = &quot;insert into `tablename` (`field1`,`field2`,`datum`)
values (&#039; &quot; . $f1val . &quot; &#039; , &#039; &quot; . $f2val . &quot; &#039; , &#039; &quot; . $datum . &quot; &#039; ) &quot;;</description>
		<content:encoded><![CDATA[<p>First, don&#8217;t use &#8220;timestamp&#8221;: that is UNIX time stamp: the number of seconds since January 1 1970 00:00:00 GMT</p>
<p>Set the column variable as &#8220;datetime&#8221; type with the default value 0000-00-00 00:00:00 (for a format YYYY:MM:DD HH:MM:SS), and call this column &#8220;datum&#8221; (don&#8217;t use &#8220;date&#8221;, &#8220;datetime&#8221; or &#8220;timestamp&#8221;!: reserved words)<br />
Advantage of this format: easy sorting!</p>
<p>When inserting, use:<br />
$datum = date ( &#8220;Y-m-d H:i:s&#8221;);<br />
This will get current time and date, correctly formatted.<br />
Your sql:<br />
$sql = &#8220;insert into `tablename` (`field1`,`field2`,`datum`)<br />
values (&#8216; &#8221; . $f1val . &#8221; &#8216; , &#8216; &#8221; . $f2val . &#8221; &#8216; , &#8216; &#8221; . $datum . &#8221; &#8216; ) &#8220;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin M</title>
		<link>http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/comment-page-1/#comment-1271</link>
		<dc:creator>Edwin M</dc:creator>
		<pubDate>Fri, 19 Feb 2010 16:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.weez.com/2010/02/how-do-i-make-my-mysql-table-automatically-make-a-timestamp-when-new-data-is-added/#comment-1271</guid>
		<description>in your SQL query, use the mysql function curdate()

example:

INSERT INTO table (column, date, column) VALUES (&#039;value&#039;, curdate(), &#039;value&#039;)</description>
		<content:encoded><![CDATA[<p>in your SQL query, use the mysql function curdate()</p>
<p>example:</p>
<p>INSERT INTO table (column, date, column) VALUES (&#8216;value&#8217;, curdate(), &#8216;value&#8217;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

