<?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>Pete Williams &#187; Code</title>
	<atom:link href="http://petewilliams.info/blog/category/web/code-web/feed/" rel="self" type="application/rss+xml" />
	<link>http://petewilliams.info/blog</link>
	<description>On Web Development and stuff</description>
	<lastBuildDate>Wed, 07 Dec 2011 11:36:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Generate HTML5 &lt;time&gt; tag&#8217;s datetime attribute in PHP</title>
		<link>http://petewilliams.info/blog/2010/09/generate-html5-time-tags-datetime-attribute-in-php/</link>
		<comments>http://petewilliams.info/blog/2010/09/generate-html5-time-tags-datetime-attribute-in-php/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 20:53:42 +0000</pubDate>
		<dc:creator>Pete Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://petewilliams.info/blog/?p=450</guid>
		<description><![CDATA[HTML5 now includes a <time> tag which is readable both by machines and humans. This PHP snippet will generate the machine-readable part for you.]]></description>
			<content:encoded><![CDATA[<p>Having just finished reading <a href="http://www.amazon.co.uk/Introducing-HTML-Voices-That-Matter/dp/0321687299/">Introducing HTML5</a> I&#8217;m rather excited about all the new HTML5 tags and can&#8217;t wait to get using them!</p>
<p>One of the new semantic tags is the &lt;time&gt; tag which is used to mark up dates and times so they are readable to both humans and to machines. It does this by including a datetime attribute which contains the relevent date in a standardised format.</p>
<p>For instance:</p>
<pre class="code">
&lt;p&gt;
   This post was written on &lt;time datetime="2010-09-16T21:28:29+01:00"&gt;Thursday evening&lt;/time&gt;
&lt;p&gt;
</pre>
<p>As you can see, the machine readable format is &#8220;YYYY-MM-DD&#8221; with a &#8220;T&#8221; to separate the time in the 24-hour format HH:MM. It ends with your timezone&#8217;s offset from <acronym title="Coordinated Universal Time">UTC</acronym>/<acronym title="Greenwich Mean Time">GMT</acronym>.</p>
<h3>UPDATE</h3>
<p><strong>Ignore everything that follows! As clever commenters pointed out, there is actually a PHP constant for this format &#8211; <em>DATE_W3C</em>. All you need to get the current time is…</strong></p>
<pre class="code">
&lt;?php echo date(DATE_W3C); ?&gt;
</pre>
<p><strong>All that follows, from the original post, is left for reference only…</strong></p>
<p>To make this easier to generate when dealing with dates in PHP, I have written a function to do this for me, which is below. Feel free to use it and let me know of any suggestions for improvement.</p>
<p>To use the function, pass in a unix timestamp or leave blank to use the current time.</p>
<pre class="code">
&lt;?php

/**
 * formats the date passed into format required by 'datetime' attribute of <time> tag
 * if no intDate supplied, uses current date.
 * @author Pete Williams
 * @link http://petewilliams.info/blog/2010/09/generate-html5-time-tags-datetime-attribute-in-php/
 * @param intDate integer optional
 * @return string
 **/
function getDateTimeValue( $intDate = null ) {

	$strFormat = 'Y-m-d\TH:i:sP';
	$strDate = $intDate ? date( $strFormat, $intDate ) : date( $strFormat ) ; 

	return $strDate;
}

echo getDateTimeValue();
</pre>
<p>Example: <a href="http://petewilliams.info/datetime.php">view current time in datetime format</a>.</p>
<p><em>Buy <a href="http://www.networksolutions.com/domain-name-registration/index.jsp">domain names</a> for just $13/year.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://petewilliams.info/blog/2010/09/generate-html5-time-tags-datetime-attribute-in-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Display HTML OL/UL list as comma-separated sentence with CSS</title>
		<link>http://petewilliams.info/blog/2010/04/display-html-olul-list-as-comma-separated-sentence/</link>
		<comments>http://petewilliams.info/blog/2010/04/display-html-olul-list-as-comma-separated-sentence/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 22:56:15 +0000</pubDate>
		<dc:creator>Pete Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://petewilliams.info/blog/?p=438</guid>
		<description><![CDATA[On a site I&#8217;m currently working on, it seemed best to display an OL as a list in sentence form. For example: &#60;ul class="commaList"&#62; &#60;li&#62;one&#60;/li&#62; &#60;li&#62;two&#60;/li&#62; &#60;li&#62;three&#60;/li&#62; &#60;li&#62;four&#60;/li&#62; &#60;/ul&#62; Would display as: One, two, three and four. In case this CSS is of any use to anyone else, I&#8217;ve published it as a snippet below. [...]]]></description>
			<content:encoded><![CDATA[<p>On a site I&#8217;m currently working on, it seemed best to display an OL as a list in sentence form.</p>
<p>For example:</p>
<pre class="code">
&lt;ul class="commaList"&gt;
	&lt;li&gt;one&lt;/li&gt;
	&lt;li&gt;two&lt;/li&gt;
	&lt;li&gt;three&lt;/li&gt;
	&lt;li&gt;four&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Would display as: <em>One, two, three and four.</em></p>
<p>In case this CSS is of any use to anyone else, I&#8217;ve published it as a snippet below.</p>
<p>Please note this uses pseudo-selectors and so will not work in IE, but will gracefully degrade.</p>
<pre class="code">
/* display ordered list as comma list */
.commaList li:first-child {
	text-transform: capitalize;
}

.commaList li:after{
	content: ',';
	padding-right: 5px;
}

.commaList li:nth-last-child(2):after {
	content: '';
	padding-right: 5px;
}

.commaList li:last-child:before {
	content: 'and ';
	padding-right: 0;
}

.commaList li:last-child:after {
	content: '.';
	clear: both;
}

/* this prevents single item lists from containing commas and 'ands' */
.commaList li:only-of-type:before, .commaList li:only-of-type:after {
	content: '';
	padding: 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://petewilliams.info/blog/2010/04/display-html-olul-list-as-comma-separated-sentence/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Amazon Link Localizer Greasemonkey Script</title>
		<link>http://petewilliams.info/blog/2009/09/amazon-link-localizer-greasemonkey-script/</link>
		<comments>http://petewilliams.info/blog/2009/09/amazon-link-localizer-greasemonkey-script/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 23:29:40 +0000</pubDate>
		<dc:creator>Pete Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[add-on]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[amazon.ca]]></category>
		<category><![CDATA[amazon.co.jp]]></category>
		<category><![CDATA[amazon.co.uk]]></category>
		<category><![CDATA[amazon.com]]></category>
		<category><![CDATA[amazon.de]]></category>
		<category><![CDATA[amazon.fr]]></category>
		<category><![CDATA[amazon.jp]]></category>
		<category><![CDATA[britain]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[canada]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[france]]></category>
		<category><![CDATA[germany]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[great britain]]></category>
		<category><![CDATA[international]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[localise]]></category>
		<category><![CDATA[localize]]></category>
		<category><![CDATA[nearest]]></category>
		<category><![CDATA[regional]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[uk]]></category>
		<category><![CDATA[united kingdom]]></category>
		<category><![CDATA[user script]]></category>

		<guid isPermaLink="false">http://petewilliams.info/blog/?p=379</guid>
		<description><![CDATA[This Greasemonkey script will convert links to international Amazon sites into links to your local Amazon site.
So if I link to a product on Amazon.co.uk, and you are a US visitor, you will get a link to that same product on Amazon.com instead.]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#suggest {
	display: none;
}
</style>
<p>This Greasemonkey script will convert links to international Amazon sites into links to your local Amazon site.<br />
So if I link to a product on Amazon.<span id="tldNot">co.uk</span>, you will get a link to that same product on Amazon.<span id="tld">com</span> instead.</p>
<p><a href="http://www.greasespot.net/">Greasemonkey</a> is an add-on for Firefox that allows you to run user-generated scripts on the websites you visit. If you haven&#8217;t got it yet, <a href="https://addons.mozilla.org/firefox/748/">download it now</a>, as you&#8217;ll need it to install the below script.</p>
<p>Once you&#8217;ve installed Greasemonkey, simply click the below link to install the script.</p>
<div id="suggest">
<p>As you&#8217;re visiting from <span id="country">US</span>, you&#8217;re probably looking for the Amazon.<span id="tld2">com</span> Script, right?</p>
<p><strong>Download</strong>: <a href="/files/gm/amazon.us.user.js" id="download" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.<span id="tld3">com</span> Link Localiser</a> (or <a href="" onclick="return showOptions()">see all options</a>)</p>
</div>
<div id="all_scripts">
Download the script for your local Amazon site:</p>
<ul>
<li><a href="/files/gm/amazon.ca.user.js" id="ca" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.ca Link Localiser</a></li>
<li><a href="/files/gm/amazon.co.uk.user.js" id="uk" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.co.uk Link Localiser</a></li>
<li><a href="/files/gm/amazon.com.user.js" id="us" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.com Link Localiser</a></li>
<li><a href="/files/gm/amazon.de.user.js" id="de" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.de Link Localiser</a></li>
<li><a href="/files/gm/amazon.fr.user.js" id="fr" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.fr Link Localiser</a></li>
<li><a href="/files/gm/amazon.jp.user.js" id="jp" onclick="pageTracker._trackPageview( 'download_amzn_gm_script' );">Amazon.jp Link Localiser</a></li>
</ul>
</div>
<h3>Updates</h3>
<p><a href="http://twitter.com/PeteWilliams">Follow me on Twitter</a> to be sure you hear about new updates.</p>
<p><script type="text/javascript" src="http://js.petewilliams.info/gm.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://petewilliams.info/blog/2009/09/amazon-link-localizer-greasemonkey-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Amazon Affiliate Link Localizer WordPress Plugin</title>
		<link>http://petewilliams.info/blog/2009/09/amazon-affiliate-link-localizer-wordpress-plugin/</link>
		<comments>http://petewilliams.info/blog/2009/09/amazon-affiliate-link-localizer-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 06:44:41 +0000</pubDate>
		<dc:creator>Pete Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[affiliate marketing]]></category>
		<category><![CDATA[affiliates]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[amazon.ca]]></category>
		<category><![CDATA[amazon.co.jp]]></category>
		<category><![CDATA[amazon.co.uk]]></category>
		<category><![CDATA[amazon.com]]></category>
		<category><![CDATA[amazon.de]]></category>
		<category><![CDATA[amazon.fr]]></category>
		<category><![CDATA[amazon.jp]]></category>
		<category><![CDATA[associate]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[improve referrals]]></category>
		<category><![CDATA[improve sales]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[plug-in]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[referral]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[weblog]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://petewilliams.info/blog/?p=366</guid>
		<description><![CDATA[This Wordpress plugin changes any Amazon links on your site to use your affiliate ID. It also changes the link to point to the user's local Amazon store.

So if your visitor is visiting form the UK they'll get a link to Amazon.co.uk, if they're visiting from the US they'll get a link to the same product on Amazon.com.]]></description>
			<content:encoded><![CDATA[<h3>Download</h3>
<p>Current Version: <a href="http://wordpress.org/extend/plugins/amazon-affiliate-link-localizer/">Amazon Affiliate Link Localizer 1.7</a><br />
Last Updated: 22/09/2011</p>
<h3>Description</h3>
<p>This plugin not only automatically changes any Amazon link on your site to use your affiliate ID, but it also changes the link to point to the user&#8217;s local Amazon store. </p>
<p>So if your visitor is visiting from the UK they&#8217;ll get a link to Amazon.co.uk, if they&#8217;re visiting from the US they&#8217;ll get a link to the same product on Amazon.com. Initially, the script looks for a product with the same product ID as the one in your link, but if it can&#8217;t find one on the user&#8217;s local store, it will link to a search results page searching for the name of your product. This means that it will still be found even if international versions have different product IDs, and if it&#8217;s not stocked at all, your user will be shown similar alternatives.</p>
<p>All you have to do is provide all your affiliate IDs!</p>
<h3>Support</h3>
<p>If you are having any problems with the script, please <a href="http://wordpress.org/extend/plugins/amazon-affiliate-link-localizer/faq/">read the FAQ</a> which solves most common enquiries.</p>
<h3>Non-Wordpress version</h3>
<p>If you want to achieve the same result on a non-Wordpress site, you can simply install the <a href="http://petewilliams.info/blog/2009/07/javascript-amazon-associate-link-localiser/">pure JavaScript version</a>. </p>
<h3>See also: Greasemonkey Script</h3>
<p>As an Amazon user, you may also be interested in my <a href="/blog/2009/09/amazon-link-localizer-greasemonkey-script/">Amazon Link Localizer Greasemonkey Script</a> which automatically converts links to international Amazon sites into links to your local Amazon site.</p>
<p>So if I link to a product on Amazon.co.uk, and you are a US visitor, you will get a link to that same product on Amazon.com instead.</p>
<h3>Updates</h3>
<p><a href="http://twitter.com/PeteWilliams">Follow me on Twitter</a> to be sure you hear about new updates.</p>
<h3>Donations</h3>
<p>If you find this plugin helpful and it&#8217;s increasing your sales. please consider <a href="http://petewilliams.info/donate">donating just $1</a> or more to say thanks for the many, many hours I&#8217;ve spent on it. I&#8217;d really appreciate it!</p>
<h3>Disclosure</h3>
<p>If you do not insert your own affiliate IDs the script will use mine. Hopefully this will help fund my book addiction!</p>
]]></content:encoded>
			<wfw:commentRss>http://petewilliams.info/blog/2009/09/amazon-affiliate-link-localizer-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Amazon Associate Link Localiser</title>
		<link>http://petewilliams.info/blog/2009/07/javascript-amazon-associate-link-localiser/</link>
		<comments>http://petewilliams.info/blog/2009/07/javascript-amazon-associate-link-localiser/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 22:26:10 +0000</pubDate>
		<dc:creator>Pete Williams</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[affiliate marketing]]></category>
		<category><![CDATA[affiliates]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[associate]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[improve referrals]]></category>
		<category><![CDATA[improve sales]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[referral]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://petewilliams.info/blog/?p=214</guid>
		<description><![CDATA[This script ensures that your Amazon links take your international visitors to their local Amazon site, rather than yours! You'll never lose a referral sale again, as the script automatically inserts your Amazon Associate ID for the appropriate international Amazon site.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a member of <a href="https://affiliate-program.amazon.co.uk/">Amazon&#8217;s Associate program</a> for a number of years and have posted affiliate links to books discussed on this very blog. The program means that by putting my affiliate ID into any links to Amazon products, I receive a small referral fee.</p>
<p>I&#8217;ve always linked to <a href="http://www.amazon.co.uk">Amazon.co.uk</a> as that&#8217;s <em>my</em> local Amazon store, but of course that&#8217;s not necessarily true for my visitors &#8211; or yours&#8230;</p>
<p>To solve this problem, I&#8217;ve written some JavaScript and a little bit of PHP which will convert any Amazon links on your page into affiliated links to your visitor&#8217;s local Amazon store. So US visitors will get a .com link, whilst UK visitors will get a .co.uk link to the same product.</p>
<h3>Download</h3>
<ul>
<li><a href="http://uploads.petewilliams.info/amazon-localiser.zip" onclick="pageTracker._trackPageview( 'amazon-localiser.zip' );">amazon-localiser.zip</a> 4 kb</li>
</ul>
<h3>Setup</h3>
<p>Edit amazon-localiser.js to insert your regional Associate IDs into the array at the top, for example:</p>
<pre class="code">
var arrAffiliates = {
	'co.uk' : 'petewill-19',
	'com'	: 'petewill-20',
	'de'	: 'petewill05-21',
	'fr'	: 'petewill-21',
	'ca'	: 'petewill00-20',
	'jp'	: '',
	'it'	: petewill04-21',
	'cn'	: petewill-23',
	'es'	: petewill0d4-21'
};
</pre>
<p>If you do not have an ID for each country, you can just leave them blank, as above for .jp.</p>
<p>In most cases, you will also need to set the path to amazon-localiser.php, for example:</p>
<pre class="code">
var strUrlAjax = '/inc/amazon-localiser.php';
</pre>
<h3>Upload and Embed</h3>
<p>As well as linking to amazon-localiser.js you need to link to the Google JS API file (5 kb) or the script will not work. Insert the following code just before your &lt;/body&gt; tag:</p>
<pre class="code">
&lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="amazon-localiser.js"&gt;&lt;/script&gt;
</pre>
<p>Upload your modified amazon-localiser.js file, and make sure the above link points to the right location.</p>
<h3>Usage</h3>
<p>That&#8217;s it &#8211; job done! You can now just link to any product on any Amazon site with a normal, unaffiliated link and your users will get one affiliated for their country. Initially, the script looks for a product with the same product ID as the one in your link, but if it can&#8217;t find one on the user&#8217;s local store, it will link to a search results page searching for the name of your product. This means that it will still be found even if international versions have different product IDs, and if it&#8217;s not stocked at all, your user will be shown similar alternatives.</p>
<h3>Example</h3>
<p>The script is running on this page, so hopefully <a href="http://www.amazon.com/Dont-Make-Me-Think-Usability/dp/0321344758/">this example</a> should be affiliated specially for you!</p>
<h3>Updates</h3>
<p><a href="http://twitter.com/PeteWilliams">Follow me on Twitter</a> to be sure you hear about new updates.</p>
<h3>Donations</h2>
<p>If you find this plugin helpful and it’s increasing your sales. please consider <a href="http://petewilliams.info/donate">donating just $1</a> or more to say thanks for the many, many hours I’ve spent on it. I’d really appreciate it!</p>
<h3>Disclosure</h3>
<p>If you do not insert your own affiliate IDs the script will use mine. Hopefully this will help fund my book addiction!</p>
]]></content:encoded>
			<wfw:commentRss>http://petewilliams.info/blog/2009/07/javascript-amazon-associate-link-localiser/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

