<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rachael F. Arnold » Front-end Dev</title>
	
	<link>http://www.rachaelarnold.com</link>
	<description>…is a front-end web developer and a sucker for pulpy paranormal lit.</description>
	<lastBuildDate>Thu, 02 Feb 2012 15:42:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<feedburner:info uri="front-enddevrachaelarnoldonline" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://www.rachaelarnold.com/dev/feed" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://www.rachaelarnold.com/dev/feed" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Fwww.rachaelarnold.com%2Fdev%2Ffeed" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Creating Quarter-Circles in Adobe Illustrator</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/3aE8o9VMiRc/creating-quarter-circles-in-adobe-illustrator</link>
		<comments>http://www.rachaelarnold.com/dev/archive/creating-quarter-circles-in-adobe-illustrator#comments</comments>
		<pubDate>Thu, 02 Feb 2012 12:00:29 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=805</guid>
		<description><![CDATA[Here’s a quick way to draw a quarter-circle in Adobe Illustrator. It involves using just one tool: the arc tool. These instructions will work in Adobe Illustrator from CS–CS5. How to create a quarter-circle (or quarter-ellipse) in Illustrator Select the arc tool. (Click and hold the straight-line–segment tool to bring up the sub-menu of additional&#160;&#8230; <a href="http://www.rachaelarnold.com/dev/archive/creating-quarter-circles-in-adobe-illustrator">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here’s a quick way to draw a quarter-circle in Adobe Illustrator. It involves using just one tool: the <strong>arc tool</strong>. </p>
<p class="success">These instructions will work in Adobe Illustrator from CS–CS5.</p>
<h2>How to create a quarter-circle (or quarter-ellipse)  in Illustrator</h2>
<ol>
<li><img src="http://www.rachaelarnold.com/media/qtr-circle-tool.png" alt="" title="qtr-circle-tool" width="214" height="241" class="alignnone size-full wp-image-809 right" /> Select the <strong>arc tool</strong>. (Click and hold the straight-line–segment tool to bring up the sub-menu of additional line-segment tools)</li>
<li>Use the <strong>arc tool</strong> to make your quarter-circle:
<dl>
<dt>A. Freehand method</dt>
<dd>
Before drawing a freehand quarter-circle for the first time, you <strong>must</strong> use the exact-size method to enable closed-shape drawing. If you do not, you will only get the curved line, not the whole the shape.<br />
<strong>Quarter-circle:</strong> Hold down the <kbd>shift</kbd> key on your keyboard, click and drag to draw a quarter-circle of the desired size.<br />
<strong>Quarter-elipse:</strong> Click and drag to draw a quarter-elipse of the desired size.</dd>
<dt>B. Exact-size method</dt>
<dd>Click once anywhere on your artboard to open the arc tool options dialogue.</p>
<div class="figure center"><img src="http://www.rachaelarnold.com/media/qtr-circle-dialog.png" alt="" title="qtr-circle-dialog" width="486" height="353" class="alignnone size-full wp-image-807" /></div>
<p>Type in your desired dimensions for the radius of your quarter-circle, and select <strong>Closed</strong> from the <em>Type</em> drop-down. If your y-axis and x-values are equal, you will be drawing a quarter-circle, but if they differ, you will draw a quarter-ellipse.</p>
<p>Click <em>ok</em>.
</dd>
</dl>
</li>
<li><strong>Success</strong>. You now have a quarter circle. You can change the fill, size, stroke, etc as with any other shape.
<div class="figure center"><img src="http://www.rachaelarnold.com/media/qtr-circle.png" alt="" title="qtr-circle" width="468" height="392" class="alignnone size-full wp-image-810" /></div>
<div class="figure center"><img src="http://www.rachaelarnold.com/media/qtr-circle-in-circle.png" alt="" title="qtr-circle-in-circle" width="468" height="422" class="alignnone size-full wp-image-808" /></div>
</li>
</ol>

<p><a href="http://feedads.g.doubleclick.net/~a/JfjYRkgnmmh_ZmOfrF7aZ6ln7bo/0/da"><img src="http://feedads.g.doubleclick.net/~a/JfjYRkgnmmh_ZmOfrF7aZ6ln7bo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JfjYRkgnmmh_ZmOfrF7aZ6ln7bo/1/da"><img src="http://feedads.g.doubleclick.net/~a/JfjYRkgnmmh_ZmOfrF7aZ6ln7bo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=3aE8o9VMiRc:9qJGYpbvWJQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=3aE8o9VMiRc:9qJGYpbvWJQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=3aE8o9VMiRc:9qJGYpbvWJQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=3aE8o9VMiRc:9qJGYpbvWJQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=3aE8o9VMiRc:9qJGYpbvWJQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=3aE8o9VMiRc:9qJGYpbvWJQ:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/3aE8o9VMiRc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/creating-quarter-circles-in-adobe-illustrator/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/creating-quarter-circles-in-adobe-illustrator</feedburner:origLink></item>
		<item>
		<title>How to Schedule Planned Maintenance Using RewriteEngine</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/oohGLkZePOA/how-to-schedule-planned-maintenance-using-rewriteengine</link>
		<comments>http://www.rachaelarnold.com/dev/archive/how-to-schedule-planned-maintenance-using-rewriteengine#comments</comments>
		<pubDate>Tue, 17 Jan 2012 17:30:28 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Censorship]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Server-side]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=803</guid>
		<description><![CDATA[… or how I set my sites up to go black tomorrow in protest of SOPA and PIPA. You might not see this prior to that blackout, but it has useful applications for other things—essentially any time you want to do a redirect that has a specific schedule. If you are running your sites on&#160;&#8230; <a href="http://www.rachaelarnold.com/dev/archive/how-to-schedule-planned-maintenance-using-rewriteengine">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>… or how I set my sites up to go black tomorrow in protest of <abbr title="Stop Online Piracy Act">SOPA</abbr> and <abbr title="Protect Intellectual Property">PIPA</abbr>. You might not see this prior to that blackout, but it has useful applications for other things—essentially any time you want to do a redirect that has a specific schedule.</p>
<p>If you are running your sites on an Apache server with the rewrite module, scheduling a temporary redirect to a maintenance page is pretty simple:</p>
<pre><code># MAINTENANCE REDIRECT
RewriteEngine on
RewriteCond %{TIME} >20120118000001 [NC]
RewriteCond %{TIME} <20120118235959 [NC]
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteRule ^(.*)$ /maintenance.html [R=307,L]
</code></pre>
<p>To explain the code:</p>
<dl>
<dt>Line 2: <code>RewriteEngine on</code></dt>
<dd>Turns on the RewriteEngine, if it isn’t already.</dd>
<dt>Line 3: <code>RewriteCond %{TIME} >20120118000001 [NC]</code></dt>
<dd>Checks to see if the date is greater than a specific time. In this case 2012-01-18 00:00:01.</dd>
<dt>Line 4: <code>RewriteCond %{TIME} <20120118235959 [NC]</code></dt>
<dd>Checks to see if the date is less than a specific time. In this case 2012-01-18 23:59:59.</dd>
<dt>Line 5: <code>RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]</code></dt>
<dd>Checks to be sure that you’re not trying to access the maintenance page itself, otherwise we’d end up in a redirect loop.</dd>
<dt>Line 6: <code>RewriteRule ^(.*)$ /maintenance.html [R=307,L]</code></dt>
<dd>If all of the above conditions are true, it does a temporary (307) redirect to your maintenance page.</dd>
</dl>
<p>Here’s the code again, with the variables you need to modify italicized.</p>
<pre><code># MAINTENANCE REDIRECT
RewriteEngine on
RewriteCond %{TIME} ><var><i>20120118000001</i></var> [NC]
RewriteCond %{TIME} <<var><i>20120118235959</i></var> [NC]
RewriteCond %{REQUEST_URI} !<var><i>/maintenance.html</i></var>$ [NC]
RewriteRule ^(.*)$ <var><i>/maintenance.html</i></var> [R=307,L]
</code></pre>
<p>Drop it in your .htaccess file, and you should be good to go.</p>
<h2>What time value should I use?</h2>
<p>We’re talking server time, so your time will be based on what your server setting is. Mine is set to EST, although it gets funky about Daylight Savings Time sometimes, so it might be off by an hour. If you know your server is running 3 hours slower than your timezone, adjust your times by 3 hours.</p>
<p>Then, figure out your date and time in the format <code>YYYY-MM-DD HH:MM:SS</code> and remove anything that isn’t a number: <code>YYYYMMDDHHMMSS</code>.</p>
<h2>Why are you doing a redirect instead of rewrite?</h2>
<p>I like to make it very clear to search engines that we’re on a new page and it is only temporary, so no caching should happen. If a search engine hits my homepage and I’ve rewritten the URI, the search engine thinks that my maintenance content should be indexed, which I definitely do not want to happen. Instead, it knows that there was a redirect.</p>
<p>You want the redirect to be temporary (307) so that the search engines know to continue to request the original URI in the future, and not the maintenance page.</p>
<h2>What is this SOPA and PIPA stuff?</h2>
<p>The American legislative bodies are both currently considering bills that will allow easy censorship on the Web in the name of protecting copyright and intellectual property. A good analogy is that the bills are kind of like trying to kill a squirrel with an atomic bomb. As someone who is both a Web developer and creative professional, I strongly believe that this bill will hinder creative and economic progress as well as the dissemination of information. </p>
<p>If you’re reading this on Jan 17, or any day after Jan 18, you can <a href="http://en.wikipedia.org/wiki/PROTECT_IP_Act" rel="external">learn more on Wikipedia</a>, but it will be blacked out on Jan 18. Of course, your favorite search engine will surely return plenty of hits as well.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/qZOYTjC8zR5PmhpRKd394mwai2E/0/da"><img src="http://feedads.g.doubleclick.net/~a/qZOYTjC8zR5PmhpRKd394mwai2E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/qZOYTjC8zR5PmhpRKd394mwai2E/1/da"><img src="http://feedads.g.doubleclick.net/~a/qZOYTjC8zR5PmhpRKd394mwai2E/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=oohGLkZePOA:t-aJnZAsU_s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=oohGLkZePOA:t-aJnZAsU_s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=oohGLkZePOA:t-aJnZAsU_s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=oohGLkZePOA:t-aJnZAsU_s:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=oohGLkZePOA:t-aJnZAsU_s:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=oohGLkZePOA:t-aJnZAsU_s:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/oohGLkZePOA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/how-to-schedule-planned-maintenance-using-rewriteengine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/how-to-schedule-planned-maintenance-using-rewriteengine</feedburner:origLink></item>
		<item>
		<title>When to Use Events vs. Pageviews for Google Analytics</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/IOepsqW66vw/when-to-use-events-vs-pageviews-for-google-analytics</link>
		<comments>http://www.rachaelarnold.com/dev/archive/when-to-use-events-vs-pageviews-for-google-analytics#comments</comments>
		<pubDate>Mon, 14 Feb 2011 18:50:37 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Google Analytics]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=785</guid>
		<description><![CDATA[How to set up a schema for tracking certain things on a website is a polarizing topic. I’ve seen numerous schema that rely solely on pageviews to track everything—outbound link clicks, downloads, modal dialogs, etc—and the creator is dogmatic about the approach. But, semantically speaking, one of those three actions is a legitimate pageview; two&#160;&#8230; <a href="http://www.rachaelarnold.com/dev/archive/when-to-use-events-vs-pageviews-for-google-analytics">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How to set up a schema for tracking certain things on a website is a polarizing topic. I’ve seen numerous schema that rely solely on pageviews to track everything—outbound link clicks, downloads, modal dialogs, etc—and the creator is dogmatic about the approach. But, semantically speaking, one of those three actions is a legitimate pageview; two aren’t. They’re events. I’m admittedly zealous when it comes to semantic use of Web technologies, but let’s face it: it makes for intelligent information architecture.</p>
<p class="tip">A good philosophy for tracking is: <strong>if new information is shown <em>in the browser</em>, at an <em>address owned by you</em>, it is a pageview.</strong> Everything else is an event.</p>
<h2>Tracking link clicks</h2>
<p>The short answer: <strong>tracking a link is tracking an event.</strong></p>
<p>For instance, clicking on an outbound link does not result in a pageview <strong>for your website.</strong> Viewers are not looking at content on your site. Thus, <strong>an outbound link click is an event.</strong></p>
<p>Clicking on a related link—such as to another similar blog post—is not a pageview, it is an event. The pageview itself will be tracked when the new page loads, but if you want to track the actual link click, you should register an event. <strong>Otherwise, you’ll be double tracking pageviews or tracking pageviews for a single page under multiple paths.</strong> Neither is ideal or desirable in an intelligent tracking schema.</p>
<p>Clicking a link that triggers a popup is covered in:</p>
<h2>Tracking pop-up, modal, or ajax-inserted content</h2>
<p>Are you tracking this based on link clicks? Why?</p>
<p>When tracking a popup, you should add tracking code to the popup file. The new window is a pageview. There’s no reason to track the link click as the pageview when you can add basic code to the popup and let Google handle it all.</p>
<p>For modal or ajax-inserted content, proper tracking means triggering a pageview when the content is shown. This is different from when the triggering link is clicked. Most plugins that allow modal dialogs or on-screen popups have an API that features some sort of <code>onShow</code> or <code>afterRendering</code> hook. This is the best place to put your pageview tracking. And yes, this is a pageview, because it is showing new content.</p>
<p>There are some cases where the link <em>should</em> be tracked, and <em>those should be tracked as events</em>. For instance, if you have a modal or popup contact form, you’ll want to track <em>a pageview</em> when the form is displayed, and <em>an event</em> to track which page the form is on or which link is used to display the form. Two different types of tracking that happen at two different (but very close together) points in the interaction.</p>
<h2>The tricky case of PDF documents</h2>
<p>PDF documents are one case where I entertain either option, but that is because there are two possible ways that PDFs extend the website: as downloadable content or as browser-viewable content. Older browsers and the default installation of Firefox treat PDFs as downloads. They are not displayed in-browser. Thus, under my definition of a pageview, clicking on a PDF link is an event. Think of it this way: we know that the user clicked the link, but we can’t be sure that the user actually downloaded or opened the document, so there’s no empirical evidence that there was a pageview. </p>
<p>However, modern browsers like Safari and Chrome, and certain mobile platforms will open PDF files seamlessly. In that case, for most intents and purposes, clicking a link results in a definite pageview. </p>
<p>Example cases:</p>
<dl>
<dt>Server forces PDF download, will not serve in browser</dt>
<dd>Event. There is no possibility the page is viewed in the browser. Any content is downloadable, not viewable.</dd>
<dt>PDF is provided because resources/desire/ability to convert to Web are not available, but is considered Web content</dt>
<dd>Pageview. There is a possibility that the page will be viewed in the browser, and that is the intended functionality anyway.</dd>
<dt>File is of a form or tutorial intended for printing</dt>
<dd>Event. The intent is not to view the content, but to provide a format for printing and interacting with outside of the Web. This is not pageview content.</dd>
</dl>
<p>In most situations where I’ve implemented tracking for PDFs, their use has fallen under the <em>event</em> philosophy, but I do see instances where a pageview does make sense.</p>
<p class="call-to-comment">How do you make decisions about pageviews or events? How do you use the resulting data?</p>
<p class="note">This post follows <a href="http://www.rachaelarnold.com/dev/archive/how-to-check-if-google-analytics-click-tracking-is-triggered" rel="prev">How to Check if Google Analytics Click Tracking is Triggered</a>, a post about debugging your events and pageview code. I hope to follow this with a tutorial about implementing JavaScript for this tracking.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/M2aU74BuyEsW4oOQBQMWLbK6LDw/0/da"><img src="http://feedads.g.doubleclick.net/~a/M2aU74BuyEsW4oOQBQMWLbK6LDw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/M2aU74BuyEsW4oOQBQMWLbK6LDw/1/da"><img src="http://feedads.g.doubleclick.net/~a/M2aU74BuyEsW4oOQBQMWLbK6LDw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=IOepsqW66vw:9iCP15lNPKg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=IOepsqW66vw:9iCP15lNPKg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=IOepsqW66vw:9iCP15lNPKg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=IOepsqW66vw:9iCP15lNPKg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=IOepsqW66vw:9iCP15lNPKg:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=IOepsqW66vw:9iCP15lNPKg:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/IOepsqW66vw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/when-to-use-events-vs-pageviews-for-google-analytics/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/when-to-use-events-vs-pageviews-for-google-analytics</feedburner:origLink></item>
		<item>
		<title>How to Check If Google Analytics Click Tracking is Triggered</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/DBfpQX0_9oM/how-to-check-if-google-analytics-click-tracking-is-triggered</link>
		<comments>http://www.rachaelarnold.com/dev/archive/how-to-check-if-google-analytics-click-tracking-is-triggered#comments</comments>
		<pubDate>Wed, 09 Feb 2011 12:00:59 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=784</guid>
		<description><![CDATA[When I add new Event or PageView tracking code that is bound to click events, I want to be sure that the tracking code is fired without waiting for a site visitor to trigger it (or in some cases before the code is even on a live page). Because my own traffic is filtered out&#160;&#8230; <a href="http://www.rachaelarnold.com/dev/archive/how-to-check-if-google-analytics-click-tracking-is-triggered">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I add new Event or PageView tracking code that is bound to <code>click</code> events, I want to be sure that the tracking code is fired without waiting for a site visitor to trigger it (or in some cases before the code is even on a live page). Because my own traffic is filtered out of all of my Google Analytics reports, I can’t rely on my clicks to show in my reports (not to mention the delay). But, even with the filter in place, the clicks <em>are</em> sent to Google, and I can check to be sure they’re sending the right information in Firefox using  <a href="http://getfirebug.com/" rel="external">Firebug</a>’s Net panel. Here’s how.</p>
<h2>Enable the Net tab</h2>
<p>If you don’t already have Firebug installed in Firefox, <a href="http://getfirebug.com/" rel="external">get it</a>, because you need it for this.</p>
<p>Once it’s installed, enable the <strong>Net</strong> panel.</p>
<div class="figure center"><img src="http://www.rachaelarnold.com/media/enable-firebug.png" alt="" title="enable-firebug" width="489" height="133" /></div>
<p>Load the page you want to test. Once you do, you’ll see a lot of stuff pop up in the Firebug Net panel. One of my posts looks something like:</p>
<div class="figure center"><a href="http://www.rachaelarnold.com/media/firebug-net.png"><img src="http://www.rachaelarnold.com/media/firebug-net-560x336.png" alt="" title="firebug-net" width="468" height="280" /></a></div>
<h2>Look for the PageView</h2>
<p>Once you have enabled the Net panel, you can see if your Google code triggers the initial pageview. Look through the requests for one that starts with <strong>_utm.gif?</strong>. Expand it by clicking on the arrow to the left of it.</p>
<div class="figure center"><a href="http://www.rachaelarnold.com/media/pageview.png"><img src="http://www.rachaelarnold.com/media/pageview-560x228.png" alt="" title="pageview" width="468" height="190" class="alignnone size-large wp-image-791" /></a></div>
<p>Looking at the <strong>params</strong> tab (it defaults to <strong>headers</strong>), you can see the information being passed to Google. The first line is your unique tracking ID. You’ll also see your page title, the domain, and most importantly, the URL being passed.</p>
<p>If you don’t find the _utm.gif? entry, something is wrong with your basic GA tracking code and no data is being sent to Google.</p>
<h2>Trigger your event or new pageview and find the tracking info</h2>
<p>After verifying that the GA code is tracking the pageview, you can see if your <code>click</code> event code is working. To do so, trigger an event that you’ve attached tracking code to. In my screenshot, I open an external link, which I’ve coded to trigger a GA event. It’s important that if you are triggering a link to a new page that you open it in a new tab or window so that your Firebug Net panel still tracks the original page.  </p>
<p>A new <strong>_utm.gif?</strong> line should show up in the Net panel. Expand this new tab. If you triggered another pageview, the <strong>params</strong> will look similar to those mentioned earlier. Events look a bit different.</p>
<div class="figure center"><a href="http://www.rachaelarnold.com/media/event-outbound.png"><img src="http://www.rachaelarnold.com/media/event-outbound-560x200.png" alt="" title="event-outbound" width="468" height="167" /></a>
<p class="caption">Click to view larger version</p>
</div>
<p>The important field here is <strong>utme</strong>, which shows the information you passed in the <code>_trackEvent</code> call. The arguments you passed to <code>_trackEvent</code> are separated by asterisks. Mine reads <code>Outbound Link*us.php.net/strtotime*Why is date() returning 12/31/1969</code>. This is because I track my outbound links under the <code>category</code> <strong>Outbound Link</strong>, with the external URL as the <code>action</code> and the <code>h1</code> text on the page the call was triggered from as the <code>label</code>.</p>
<p>Yours will likely differ depending on your schema for event tracking. </p>
<p>Again, if you don’t find this new _utm.gif? call in the Net panel, your <code>click</code> event code isn’t running, or the GA _trackEvent/_trackPageview code is set up incorrectly. You’ll need to debug it, then check again.</p>
<p class="call-to-comment">Now you know how to check if your code is working. What do you use Google Event or Pageview tracking for?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Egc2GlfU6UXKugOXjgwVA5g07sI/0/da"><img src="http://feedads.g.doubleclick.net/~a/Egc2GlfU6UXKugOXjgwVA5g07sI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Egc2GlfU6UXKugOXjgwVA5g07sI/1/da"><img src="http://feedads.g.doubleclick.net/~a/Egc2GlfU6UXKugOXjgwVA5g07sI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=DBfpQX0_9oM:TsILVM4Pfzs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=DBfpQX0_9oM:TsILVM4Pfzs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=DBfpQX0_9oM:TsILVM4Pfzs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=DBfpQX0_9oM:TsILVM4Pfzs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=DBfpQX0_9oM:TsILVM4Pfzs:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=DBfpQX0_9oM:TsILVM4Pfzs:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/DBfpQX0_9oM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/how-to-check-if-google-analytics-click-tracking-is-triggered/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/how-to-check-if-google-analytics-click-tracking-is-triggered</feedburner:origLink></item>
		<item>
		<title>New Project Launch</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/FjZg7hFif9w/new-project-launch</link>
		<comments>http://www.rachaelarnold.com/dev/archive/new-project-launch#comments</comments>
		<pubDate>Mon, 10 Jan 2011 18:00:38 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[New Project]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=730</guid>
		<description><![CDATA[I launched a new Web project a couple of months ago, but am just now getting a chance to post about it. The project is the Student Loan Facts Page, a site and blog about student loans. The importance of it to this Front-end dev blog, however, is that I want to let you know&#160;&#8230; <a href="http://www.rachaelarnold.com/dev/archive/new-project-launch">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I launched a new Web project a couple of months ago, but am just now getting a chance to post about it. The project is the <a href="http://studentloanfactspage.com">Student Loan Facts Page</a>, a site and blog about student loans. The importance of it to this Front-end dev blog, however, is that I want to let you know my thoughts on the <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a>.</p>
<p>I’ll start with a caveat: this is a personal project, so I made a conscious decision to use elements in the design and coding that won’t work in any current release of IE. That’s not to say that IE users can’t see the site or anything, just that some stuff might be a little wonky. Like, the homepage makes use of the <code>content</code> CSS attribute to display numbers next to the six main links. </p>
<p>But my main goal with this site was to play around with WordPress a little more and start something with HTML 5. <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> seemed like a good place to start. I’m a fan of CSS resets, so that’s all there. I’m also intrigued by some of their approaches:</p>
<ul>
<li>CDN hosted jQuery with local fallback failsafe.</li>
<li>JS located at the bottom of the page.</li>
<li>IE/JS-specific classes on the <code>html</code> tag (or <code>body</code> tag, depending on which version you’re using) to allow for progressive enhancement.</li>
<li>Asynchronous Google Analytics use.</li>
<li>Forcing a scrollbar in non-IE browsers to for design consistency. </li>
<li>Consideration for <code>a:focus</code>.</li>
<li>Text input/label alignment.</li>
<li>Progressive HTML5 form error classes using the <code>:valid</code> and <code>:invalid</code> selectors.</li>
</ul>
<p>… and much more.</p>
<p>There’s also some stuff that I’m not as happy with, like non-semantic classes, but I can see why they included it. </p>
<p>As a whole, I think it’s a great start for developers who know what all of the code does. It is a very simple setup to modify as a solid basis for your own personal framework. It’s not really a straight out of the box solution, though. </p>
<p>It’s also not a great solution for a newbie to use. They’ll end up with bloated code and unnecessary stuff. Although, my current code on that site isn’t exactly pretty.</p>
<p>I’m impressed enough to use it as a jumping-off point for a redesign of this site coming later in the year, though. I hope you have a good experience with it as well.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/MjeQ5HyyVkJAs5bYhmqbTdDAgGc/0/da"><img src="http://feedads.g.doubleclick.net/~a/MjeQ5HyyVkJAs5bYhmqbTdDAgGc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/MjeQ5HyyVkJAs5bYhmqbTdDAgGc/1/da"><img src="http://feedads.g.doubleclick.net/~a/MjeQ5HyyVkJAs5bYhmqbTdDAgGc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=FjZg7hFif9w:xGFinFfK__A:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=FjZg7hFif9w:xGFinFfK__A:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=FjZg7hFif9w:xGFinFfK__A:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=FjZg7hFif9w:xGFinFfK__A:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=FjZg7hFif9w:xGFinFfK__A:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=FjZg7hFif9w:xGFinFfK__A:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/FjZg7hFif9w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/new-project-launch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/new-project-launch</feedburner:origLink></item>
		<item>
		<title>IE Change Event Delay</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/T9Zp3DqtTUY/ie-change-event-delay</link>
		<comments>http://www.rachaelarnold.com/dev/archive/ie-change-event-delay#comments</comments>
		<pubDate>Mon, 01 Nov 2010 17:56:04 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=563</guid>
		<description><![CDATA[I recently developed a sign-up form for a client that includes on-page price total calculation using JavaScript (jQuery). The premise is simple: the user provides information and specify options, then clicks a radio button to choose a specific price plan. The initial total price calculation is triggered by the change() event for the radio button elements. But, the client was concerned (and with user testing, it turned out rightly so) because in IE, the price calculation didn't happen until the user clicked somewhere else on the page. In cases where they first clicked one option, then a different one, the price would seemingly lag behind because of IE’s delayed change event firing. It was confusing to the user, but worse—confusing for me to “fix” IE’s implementation.]]></description>
			<content:encoded><![CDATA[<p>I recently developed a sign-up form for a client that includes on-page price total calculation using JavaScript (jQuery). The premise is simple: the user provides information and specify options, then clicks a radio button to choose a specific price plan. The initial total price calculation is triggered by the change() event for the radio button elements. But, the client was concerned (and with user testing, it turned out rightly so) because in IE, the price calculation didn&#8217;t happen until the user clicked somewhere else on the page. In cases where they first clicked one option, then a different one, the price would seemingly lag behind because of IE’s delayed change event firing. It was confusing to the user, but worse—confusing for me to “fix” IE’s implementation.</p>
<p class="notice">The awesome news is that this has been fixed in jQuery 1.4, but the concern is still valid for older versions (which my application was using) and straight-JavaScript implementations.</p>
<h2>The problem</h2>
<p>In Internet Explorer, the change event fires when focus leaves the form element (an event know as blur). That means that the event happens only once a user has clicked on—or used the keyboard to navigate to—another element on the page (form or other).  In cases like mine, where a user is expecting instant feedback to their click, this causes issues with user experience. Unfortunately, this isn’t exactly a “bug,” as it’s how IE handles this event in 6, 7 and 8.</p>
<p>In other browsers—Firefox, Webkit-based (Safari/Chrome) and Opera—the event fires off immediately, so in order to have consistent, intelligent operation, we have to hack IE’s basic behavior. The easiest solution is to bind your function to a different event, such as the click event, but that’s generally not the right solution. There is a better one.</p>
<h2>Why using the click event is wrong</h2>
<p>One word: accessibility. Users—whether they have a disability that restricts their use of the mouse or like to tab about the page with the keyboard for speed—don’t always use the mouse to move from form element to form element. So, if you bind your functionality to the click event, you may end up messing with a user’s workflow, which makes for unhappy visitors. In some cases, it may even make a user unable to use your application. So don’t use that as your solution.</p>
<h2>The real solution</h2>
<p>If IE needs a blur event to know that the change event should fire, give it one when the element is clicked. In jQuery, that looks something like:</p>
<pre><code>$("#element").click(function(){
	// In IE, we need to do blur then focus to trigger a change event
	if ($.browser.msie) {
		this.blur();
		this.focus();
	}
}).change(function(){ actionIWantOnChange(); });</code></pre>
<p>This code tricks IE into thinking that focus has been changed away from the element when it is clicked. But since the <code>change</code> event is also triggered, the actions attached to that event also happen. Keyboard navigability still works, because even though there is no click, the <code>change</code> event will fire when they use the keyboard to move to another field meaning the feedback is instantaneous.</p>
<p>Now, you can probably improve my above example by using better feature-sniffing to test for IE instead of the <code>browser</code> object in jQuery, but my time for creating a fix was limited—and this code gets the job done.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/p7Lax5u7e7M_QqRAQj7TlOVQ6Zc/0/da"><img src="http://feedads.g.doubleclick.net/~a/p7Lax5u7e7M_QqRAQj7TlOVQ6Zc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/p7Lax5u7e7M_QqRAQj7TlOVQ6Zc/1/da"><img src="http://feedads.g.doubleclick.net/~a/p7Lax5u7e7M_QqRAQj7TlOVQ6Zc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=T9Zp3DqtTUY:35PjrnNPGlU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=T9Zp3DqtTUY:35PjrnNPGlU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=T9Zp3DqtTUY:35PjrnNPGlU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=T9Zp3DqtTUY:35PjrnNPGlU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=T9Zp3DqtTUY:35PjrnNPGlU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=T9Zp3DqtTUY:35PjrnNPGlU:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/T9Zp3DqtTUY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/ie-change-event-delay/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/ie-change-event-delay</feedburner:origLink></item>
		<item>
		<title>A List Apart: The Survey 2010</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/jdBUU-0XzDE/a-list-apart-the-survey-2010</link>
		<comments>http://www.rachaelarnold.com/dev/archive/a-list-apart-the-survey-2010#comments</comments>
		<pubDate>Tue, 19 Oct 2010 17:39:02 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Employment]]></category>
		<category><![CDATA[Surveys]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=653</guid>
		<description><![CDATA[<a class="noicon" rel="external" href="http://alistapart.com/articles/survey2010"><img title="I Took the Survey For People Who Make Websites 2010" src="http://www.rachaelarnold.com/media/I-Took-the-Survey-For-People-Who-Make-Websites-2010.gif" alt="" width="180" height="46" /></a> For the past couple of years, A List Apart has run a survey for those of us who create the Web. They collect stats about location, type of work, etc. It's quick to take, and the information is helpful. <a rel="external" href="http://alistapart.com/articles/survey2010">Go take it</a> or view the <a rel="external" href="http://aneventapart.com/alasurvey2009/">findings from last year</a>.]]></description>
			<content:encoded><![CDATA[<p><a class="noicon" rel="external" href="http://alistapart.com/articles/survey2010"><img title="I Took the Survey For People Who Make Websites 2010" src="http://www.rachaelarnold.com/media/I-Took-the-Survey-For-People-Who-Make-Websites-2010.gif" alt="" width="180" height="46" /></a> For the past couple of years, A List Apart has run a survey for those of us who create the Web. They collect stats about location, type of work, etc. It&#8217;s quick to take, and the information is helpful. <a rel="external" href="http://alistapart.com/articles/survey2010">Go take it</a> or view the <a rel="external" href="http://aneventapart.com/alasurvey2009/">findings from last year</a>.</p>
<p>Why is it important? Well, personally, I’m just kinda nosey and intrigued by data sets and enjoy seeing what the world of Web dev looks like. According to A List Apart:</p>
<blockquote cite="http://aneventapart.com/webdesignsurvey/"><p>We hope that making this data available will have a positive effect on best practices and employment, and will enhance public understanding of, and respect for, our profession.</p></blockquote>
<p>So go on, and help them out for 2010.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Q-9rNwGdly6iekTNGLJe8fq_z3c/0/da"><img src="http://feedads.g.doubleclick.net/~a/Q-9rNwGdly6iekTNGLJe8fq_z3c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Q-9rNwGdly6iekTNGLJe8fq_z3c/1/da"><img src="http://feedads.g.doubleclick.net/~a/Q-9rNwGdly6iekTNGLJe8fq_z3c/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=jdBUU-0XzDE:5g-YYPpZ9eA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=jdBUU-0XzDE:5g-YYPpZ9eA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=jdBUU-0XzDE:5g-YYPpZ9eA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=jdBUU-0XzDE:5g-YYPpZ9eA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=jdBUU-0XzDE:5g-YYPpZ9eA:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=jdBUU-0XzDE:5g-YYPpZ9eA:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/jdBUU-0XzDE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/a-list-apart-the-survey-2010/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/a-list-apart-the-survey-2010</feedburner:origLink></item>
		<item>
		<title>Elegant Code Patterns—Set and Return a Variable in One Line</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/VdULEPTDmCc/set-and-return-variable-in-one-line</link>
		<comments>http://www.rachaelarnold.com/dev/archive/set-and-return-variable-in-one-line#comments</comments>
		<pubDate>Tue, 05 Oct 2010 17:58:03 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Great Code]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=612</guid>
		<description><![CDATA[I’ve been working on a Project that Never Ends™ for well… months now. Many months. The project has moved in to phase I’ve-lost-count, and the current milestone work is speed improvement. The project is a wonderful example of what goes wrong when you don’t have a detailed plan to start with, and has evolved into a terrible mess of convoluted code. The first step in any speed improvement is to reduce as much duplication as possible. One way of doing that is by caching calculations. And you can do that with a very small amount of code, using an elegant code pattern of setting and returning a variable in a single call.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sxc.hu/photo/150038" rel="source" class="noicon"><img src="http://www.rachaelarnold.com/media/150038_8248-250x187.jpg" alt="" width="250" height="187" /></a>I’ve been working on a Project that Never Ends™ for well… months now. Many months. The project has moved in to phase I’ve-lost-count, and the current milestone work is speed improvement. The project is a wonderful example of what goes wrong when you don’t have a detailed plan to start with, and has evolved into a terrible mess of convoluted code. The first step in any speed improvement is to reduce as much duplication as possible. One way of doing that is by caching calculations. And you can do that with a very small amount of code, using an elegant code pattern of setting and returning a variable in a single call.</p>
<h2>The premise</h2>
<p>When a complicated calculation is going to be used multiple times on a page, efficiency dictates saving the result (so that the calculation is only done once). So, instead of calculating the result every time you need it, why not cache the value? You can do this using a global variable and a single function. That way, any time you need the calculation, you can call the same function—including the first time—but only calculate the value once.</p>
<h2>A case study</h2>
<p>A function exists to get the total sales for a specific product during a given year. It does so by querying a database that has thousands of entries for each sales transaction. This time-expensive function is used multiple times on the page and is causing the page to take far too long to load. </p>
<p>It’s really a rather simple function:</p>
<pre><code>function getSales($customer,$year) {
     $db_record = query_database("SELECT sum(sales) as total &raquo;
                FROM sales_records WHERE customer='$customer' &raquo;
                AND year='$year'");
     return $db_record->total;
}</code></pre>
<p class="editor-note">Line breaks marked by &raquo;</p>
<p>While the above function glosses over the actual database calculation (that’s all pseudo code, the functions don’t really exist), you get the idea. It’s simple, but expensive when you’re querying many thousands of records each time.</p>
<p>By caching the result, we can reduce the page load time by quite a bit. </p>
<pre><code>$CACHE = array();
function getSales($customer,$year) {
     global $CACHE;
     if (isset($CACHE[$customer][$year])) return $CACHE[$customer][$year];
     $db_record = query_database("SELECT sum(sales) as total &raquo;
                FROM sales_records WHERE customer='$customer' &raquo;
                AND year='$year'");
     return $CACHE[$customer][$year] = $db_record->total;
}</code></pre>
<h3>Explaining the new code, line by line</h3>
<dl>
<dt><code>$CACHE = array();</code></dt>
<dd>This line of code simply creates a global variable (a variable outside the scope of our function) to use as a cache. In this case, we’re using an array.</dt>
<dt><code>global $CACHE;</code></dt>
<dd>Now that we’re in the function, we need to get access to our global variable. This line of code does just that. It declares that any time the variable <var>$CACHE</var> is used, it is referring to the global version.</dt>
<dt><code>if (isset($CACHE[$customer][$year])) return $CACHE[$customer][$year];</code></dt>
<dd>This is where the cache magic happens. If this is the second or later time the function has been called, the value has already been cached. We check to see if the correct cache value exists, and if it does, we return it. That exits the function immediately, meaning <em>we return the correct value, but don’t do the expensive calculation</em>.</dt>
<dt><code>$db_record = query_database…</code></dt>
<dd>This line is the calculation from the unoptimized function. If the result hasn’t been cached (that is, this is the first time the function has been called), we have to do the calculation. There’s no need to wrap this in an <code>else</code> clause, though, because when the previous <code>if</code> statement is true, this code is never reached.</dt>
<dt><code>return $CACHE[$customer][$year] = $db_record->total;</code></dt>
<dd>
<p>This is the magic from the title of the blog post. It sets and returns a value (the value to the right of the assignment operator [<code>=</code>]) at the same time. You’ve probably written something like this before:</p>
<pre><code>$variable = $value;
return $variable</code></pre>
<p>In PHP, however, you can do that same thing with a single line of code:</p>
<pre><code>return $variable = $value</code></pre>
<p>It’s elegant and simple. That’s what we’re doing in this line. </p>
<p class="notice"><strong>Caveat:</strong> this code pattern is wonderful for returning simple values. It doesn’t work for whole arrays. That is, you can return the value of one item in an array, as we do in the function, but you couldn’t return a whole array. That must be done with the two lines of code.</p>
</dt>
</dl>
<h2>The result</h2>
<p>I’m not going to put precise empirical evidence (execution times) on here, because your results will vary widely depending on your project and data. But, to give an idea, the project the case study is based on saw an average page load time reduction <strong>from 20s to 4s</strong>.  Not a single other thing was done to the code beyond caching the values of the calculation. Your results may see less of a savings or more. In my case, we were dealing with a database containing more than 15,000 individual records that were being looked at each time the calculation query was made.</p>
<p>Depending on your exact project, there can be more improvements to this code. For instance, lookups in a multi-dimensional array are more expensive than ones in a one-dimensional array or an integer variable. But the concept transcends projects: cache and return the value at once, and you can save precious time by not recalculating each time the function is called.</p>
<p class="call-to-comment">Have you seen or used this code pattern before? Do you love it or hate it?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/YkE6HbspGfDF6_ElJDfp_elWpPk/0/da"><img src="http://feedads.g.doubleclick.net/~a/YkE6HbspGfDF6_ElJDfp_elWpPk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YkE6HbspGfDF6_ElJDfp_elWpPk/1/da"><img src="http://feedads.g.doubleclick.net/~a/YkE6HbspGfDF6_ElJDfp_elWpPk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=VdULEPTDmCc:L86rTjraZUY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=VdULEPTDmCc:L86rTjraZUY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=VdULEPTDmCc:L86rTjraZUY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=VdULEPTDmCc:L86rTjraZUY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=VdULEPTDmCc:L86rTjraZUY:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=VdULEPTDmCc:L86rTjraZUY:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/VdULEPTDmCc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/set-and-return-variable-in-one-line/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/set-and-return-variable-in-one-line</feedburner:origLink></item>
		<item>
		<title>Elegant Code Patterns—Drop the Else When Code is Repeated</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/4Fn9xXqZb_s/drop-the-else-when-code-is-repeated</link>
		<comments>http://www.rachaelarnold.com/dev/archive/drop-the-else-when-code-is-repeated#comments</comments>
		<pubDate>Mon, 27 Sep 2010 17:54:28 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[Great Code]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=579</guid>
		<description><![CDATA[I'm working on launching a new project that has been eating up a lot of my time. Partially because any new project has a habit of eating up a lot of time, but also because I'm really focusing on using this project as a solid base for a few others, meaning I want my code to be elegant, my ideas well-executed, and my implementation in a way that means I won't want to scrap it and start over in the future as I do far too often. Part of that employing elegant code patterns. One of my most often used patterns involves dropping the <code>else</code> statement when I have code repeated in different logic clauses.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sxc.hu/photo/150038" rel="source" class="noicon"><img src="http://www.rachaelarnold.com/media/150038_8248-250x187.jpg" alt="" width="250" height="187" /></a> I&#8217;m working on launching a new project that has been eating up a lot of my time. Partially because any new project has a habit of eating up a lot of time, but also because I&#8217;m really focusing on using this project as a solid base for a few others, meaning I want my code to be elegant, my ideas well-executed, and my implementation in a way that means I won&#8217;t want to scrap it and start over in the future as I do far too often. Part of that employing elegant code patterns. One of my most often used patterns involves dropping the <code>else</code> statement when I have code repeated in different logic clauses.</p>
<h2>The premise</h2>
<p>One of the countless ways of using the <code>if…else</code> construct is to do one thing if a certain variable is one value, or do something else if it is not. A lot of times this results in duplicating code. Duplicate code is inelegant, and introduces a greater opportunity for error when, for instance, one line is changed, but its clone is not.</p>
<p>The solution: <strong>structure your code to reduce duplicate code</strong>.</p>
<h2>A case study</h2>
<p>A project is using a CMS that provides a tag to retrieve the path to a featured image for a page. If no such image exists, it returns the path for an empty filler image. There&#8217;s no way within the CMS to change what that filler image is, but this project calls for using something else as a filler.</p>
<p>The goal: display the proper featured image or correct placeholder using an <code>img</code> tag.</p>
<p>The process: get the image path, and check if it is the default filler image. If it is, change the path to the new filler. Display the correct image.</p>
<p>The inherited code looked something like this (PHP):</p>
<pre><code>$image_path = get_image_path($page);
if ($image_path == "/path/to/default_filler.png") {
   echo "&lt;img src="/path/to/desired/filler.png" alt=" " /&gt;";
} else {
   echo "&lt;img src="$image_path" alt=" " /&gt;";
}</code></pre>
<p>In this case, the logical clauses are doing the exact same thing: printing out an image tag. The only difference is the path being printed. What if you later decide to add in an <code>alt</code> value, or reuse this code on an HTML page instead of XHTML? You might forget to change both lines. There&#8217;s a more elegant way.</p>
<h2>The refined code</h2>
<p>Refining the code, we can completely drop the <code>else</code> statement. Instead of printing the tag in each clause, we simply change the value of <var>$image_path</var> to be equal to the new filler image path if it is set to the wrong one. Then, we print the image tag using the value of <var>$image_path</var>.</p>
<pre><code>$image_path = get_image_path($page);
if ($image_path == "/path/to/default_filler.png") {
    $image_path = "/path/to/desired/filler.png";
}
echo "&lt;img src="$image_path" alt=" " /&gt;";
</code></pre>
<p>Depending on your school of thought on using braces with logical constructs, you can even reduce this code to three lines. But, regardless of brace use, the refined code is a lot more elegant and maintainable than the old code.</p>
<p>Going further, in this case our code pattern was only being used once, but if you were also repeating this pattern, you would turn it into a function to be called each time rather than copying the code.</p>
<p class="call-to-comment">Any time you find yourself repeating code, especially inside of logical constructs, see if you can simplify and refine your code. It makes it easier to read, easier to update, and is often much more efficient.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/lJZi5lwhPGk2pELuqTt7kep6vOA/0/da"><img src="http://feedads.g.doubleclick.net/~a/lJZi5lwhPGk2pELuqTt7kep6vOA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lJZi5lwhPGk2pELuqTt7kep6vOA/1/da"><img src="http://feedads.g.doubleclick.net/~a/lJZi5lwhPGk2pELuqTt7kep6vOA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=4Fn9xXqZb_s:amBFCCaJhyQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=4Fn9xXqZb_s:amBFCCaJhyQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=4Fn9xXqZb_s:amBFCCaJhyQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=4Fn9xXqZb_s:amBFCCaJhyQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=4Fn9xXqZb_s:amBFCCaJhyQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=4Fn9xXqZb_s:amBFCCaJhyQ:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/4Fn9xXqZb_s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/drop-the-else-when-code-is-repeated/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/drop-the-else-when-code-is-repeated</feedburner:origLink></item>
		<item>
		<title>Why is date() Returning 12/31/1969?</title>
		<link>http://feedproxy.google.com/~r/Front-endDevRachaelArnoldOnline/~3/raDrrBYlxEs/why-is-date-returning-wrong</link>
		<comments>http://www.rachaelarnold.com/dev/archive/why-is-date-returning-wrong#comments</comments>
		<pubDate>Thu, 09 Sep 2010 17:44:22 +0000</pubDate>
		<dc:creator>Rae</dc:creator>
				<category><![CDATA[Front-end Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.rachaelarnold.com/?p=516</guid>
		<description><![CDATA[In PHP, a good sign that something is wrong with your date data or logic is when you start seeing dates displayed as “12/31/1969” (or however you specified the format). Unfortunately, there’s not a one-fits-all solution to that, since it could be caused by any number of things, but ultimately, the root of the matter is that you’re passing an invalid timestamp into <code>date()</code>. So while I can’t answer what’s wrong, I can tell you why it is happening.]]></description>
			<content:encoded><![CDATA[<p><a class="noicon" rel="external" href="http://www.sxc.hu/photo/927767/"><img src="http://www.rachaelarnold.com/media/927767_91362481-250x166.jpg" alt=" " width="250" height="166" /></a> In PHP, a good sign that something is wrong with your date data or logic is when you start seeing dates displayed as “12/31/1969” (or however you specified the format). Unfortunately, there’s not a one-fits-all solution to that, since it could be caused by any number of things, but ultimately, the root of the matter is that you’re passing an invalid timestamp into <code>date()</code>. So while I can’t answer what’s wrong in your specific code, I can tell you why it is happening.</p>
<h2>All about <code>date()</code></h2>
<p>In PHP, the date function takes in a Unix timestamp, then formats it according to the format mask you provide. To display today’s date, you only need to provide a mask, no timestamp, as the timestamp argument will default to the value of <code>time()</code> (as in, right that moment).</p>
<p>In code:</p>
<pre><code>&lt;?php echo date("m/d/Y"); ?&gt;</code></pre>
<p>Which evaluated as <code>02/02/2012</code> when this page loaded.</p>
<p>But when you want to display a date in the past or future, you have to provide a timestamp. A Unix timestamp to be exact.</p>
<h2>The Unix timestamp</h2>
<p>The Unix timestamp is defined in <strong>seconds since the <dfn><a title="Learn more about the Unix Epoch at Wikipedia" rel="external" href="http://en.wikipedia.org/wiki/Unix_Epoch">Unix Epoch</a></dfn></strong>, otherwise known as  <strong>January 1, 1970 at 0:00:00 UTC</strong>.</p>
<p>In PHP, you can retrieve the timestamp using the time function. In code:</p>
<pre><code>&lt;?php echo time() ?&gt;</code></pre>
<p>Which evaluated as <code>1328198033</code> when this page loaded.</p>
<p>In order to get a timestamp value from a time string, such as <code>"2009-09-09"</code>, you can use <code>strtotime()</code>, which will try to parse many different types of date strings. <a title="strtotime() on php.net" rel="external" href="http://us.php.net/strtotime">Learn more about the <code>strtotime</code> function at in the PHP manual</a>. So if I wanted to use PHP to format that date as something different, say to insert into a MySQL database, I would use code that looks something like:</p>
<pre><code>&lt;?php $date = date("Y-m-d H:i:s",strtotime("09/09/2009")); ?&gt;</code></pre>
<p>Which sets date equal to <code>"2009-09-09 00:00:00"</code>.</p>
<p>But when you pass a string to <code>strtotime()</code> that the function can’t parse, or try passing a date string directly to <code>date()</code> instead of a timestamp, <code>date()</code> can’t do anything with the invalid value.</p>
<h2>Demystifying 12/31/1969 (or 1/1/1970 for Eastern Hemisphere folk)</h2>
<p>Since the Unix timestamp is based off the Unix Epoch, <strong>an invalid timestamp defaults to to the Epoch</strong> (Thu, 01 Jan 1970 00:00:00 +0000).</p>
<p>But, <code>date()</code> displays the formatted time <strong>taking into account the timezone of the server</strong> or a timezone set with <code>date_default_timezone_set()</code>, so if your timezone is set to <span title="Like this one is">something like America/New_York (-0500)</span>, the date will be adjusted, resulting in a time that falls during 31 Dec 1969.</p>
<p>So if your server or script timezone is set to a timezone in the Western Hemisphere, any invalid timestamps will end up displayed as some incarnation of 31 Dec 1969. Likewise, in the Eastern Hemisphere, the date falls on or after the Epoch, resulting in a returned value of 1 Jan 1970.</p>
<h2>Like Y2K except worse…</h2>
<p>The concept of the Unix Epoch as the basis for time is causing some issues as we get deeper into the new millennium. For 32-bit systems, such as this server and hundreds of thousands (likely millions) of other computerized devices out there, time is finite. The systems will not be able to handle the large integer required to store the date based on the Epoch. When Tue, 19 Jan 2038 03:14:07 UTC rolls around, timestamps will rollover—to a value that equates to Fri, 13 Dec         1901 20:45:54 GMT.</p>
<p>As much as I’d like to travel back in time and see <span title="Queen Victoria died on 22 Jan 1901">the last few days of Queen Victoria’s reign</span> (oh the fashion!), that rollover will likely bring software systems crashing down. In fact, some systems have already started showing issues if they deal with dates farther than 27 years in the future. Luckily, electronics have been on a steady move toward 64-bit systems that can handle dates up to over 200 billion years in the future, but it’s not unlikely that some 32-bit systems will still be in use when 2038 rolls around even if their manufacture has slowed (or likely stopped).</p>
<p>If you’re trying to pass a perfectly valid date that falls before 13 Dec 1901 or later than 19 Jan 2038 to your PHP script, chances are you’ll see this Epoch error, because the server can’t handle that timestamp.</p>
<p>What’s your favorite 12/31/1969 story? Are you worried about the year 2038?</p>

<p><a href="http://feedads.g.doubleclick.net/~a/SUl8bJPyd3SqbHqA9qZmWFDfRqE/0/da"><img src="http://feedads.g.doubleclick.net/~a/SUl8bJPyd3SqbHqA9qZmWFDfRqE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SUl8bJPyd3SqbHqA9qZmWFDfRqE/1/da"><img src="http://feedads.g.doubleclick.net/~a/SUl8bJPyd3SqbHqA9qZmWFDfRqE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=raDrrBYlxEs:sS6mxl9FXTY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=raDrrBYlxEs:sS6mxl9FXTY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=raDrrBYlxEs:sS6mxl9FXTY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=raDrrBYlxEs:sS6mxl9FXTY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?a=raDrrBYlxEs:sS6mxl9FXTY:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/Front-endDevRachaelArnoldOnline?i=raDrrBYlxEs:sS6mxl9FXTY:-BTjWOF_DHI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Front-endDevRachaelArnoldOnline/~4/raDrrBYlxEs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rachaelarnold.com/dev/archive/why-is-date-returning-wrong/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.rachaelarnold.com/dev/archive/why-is-date-returning-wrong</feedburner:origLink></item>
	</channel>
</rss>

