<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Val Petruchek on Web-Development &#187; timestamp</title>
	<atom:link href="http://petruchek.com/tag/timestamp/feed/" rel="self" type="application/rss+xml" />
	<link>http://petruchek.com</link>
	<description>PHP, JavaScript, MySQL, Apache, CSS</description>
	<lastBuildDate>Sun, 13 Sep 2020 18:58:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>It&#8217;s not my birthday, it&#8217;s a NEW YEAR, dumbass.</title>
		<link>http://petruchek.com/2015/01/its-a-new-year-dumbass/</link>
		<comments>http://petruchek.com/2015/01/its-a-new-year-dumbass/#comments</comments>
		<pubDate>Fri, 02 Jan 2015 12:14:32 +0000</pubDate>
		<dc:creator>val</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://petruchek.com/?p=193</guid>
		<description><![CDATA[On the January 1st this year I got one very odd email from online store I purchased something from couple of years ago (BTW, it was the worst online shopping experience ever: it worked like a soviet hospital, not an &#8230; <a href="http://petruchek.com/2015/01/its-a-new-year-dumbass/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img src="http://petruchek.com/wp-content/uploads/2015/01/happy-birthday-and-happy-new-year.png" alt="happy-birthday-and-happy-new-year" width="300" height="350" class="alignnone size-full wp-image-199" align="left" style="margin:10px !important" />On the January 1st this year I got one very odd email from online store I purchased something from couple of years ago (<em>BTW, it was the worst online shopping experience ever: it worked like a soviet hospital, not an internet shop</em>).</p>
<p>Anyway, it was a &#8216;<strong>Happy Birthday</strong>&#8216; email, and no, my birthday is not the January, 1st.</p>
<p>It&#8217;s very unlikely that I entered 01/01 as my DOB: I try not to tell it to online stores when the field is not required; even when it is I prefer to enter 02/29 to minimize the number of such automated HB congratulations.</p>
<p>So it got me thinking: <strong>why on earth would their database contain 01/01 as my DOB? </strong></p>
<p>My best guess is that they are storing date of birth as a <a href="unixtimestamp.com">unix timestamp</a>. And at some point the value I provided (NULL) got converted to 0 (zero).</p>
<p>And zero seconds since the Epoch means 01/01/1970: so, their software decided I just turned 45 and sent me a happy birthday email (I didn&#8217;t think it was possible, but my opinion about that particular store got worse).</p>
<p><u>What lessons should developers learn from this story?</u></p>
<ol>
<li>Never use TIMESTAMP when you can use DATE data type. They are different, and <strong>date</strong> of birth is definitely a DATE.</li>
<li>Do not confuse NULL and zero (or empty string). NULL is a special value, meaning &#8216;NOTHING&#8217;. There are cases, when it&#8217;s the same as zero (e.g.: number of items purchased), but generally it&#8217;s not the same (as in my example with non-entered DOB).</li>
<li>Use DEFAULT values properly. 0 and NULL are not necessary the same.</li>
<li>Treat data carefully during upgrades/conversions. I&#8217;m not sure if the DOB field was there when I was registering at the website, but it could be introduced in the database later &#8211; and all old records may have got their values for DOB field set to 0 instead of NULL. </li>
</ol>
<p>In my last guess is true, I&#8217;m not the only one who got that stupid &#8216;Happy Birthday&#8217; notification when we should have received &#8216;Happy New Year&#8217; notification instead.</p>
<p><strong>Happy New Year to all (if any) readers of this blog!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://petruchek.com/2015/01/its-a-new-year-dumbass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
