<?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>technical musings</title>
	<atom:link href="http://stevedurr.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://stevedurr.com/blog</link>
	<description></description>
	<lastBuildDate>Sat, 11 Feb 2012 21:59:31 +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>Install imagick on OS X</title>
		<link>http://stevedurr.com/blog/2012/02/install-imagick-on-os-x/</link>
		<comments>http://stevedurr.com/blog/2012/02/install-imagick-on-os-x/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 15:03:19 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Apple OS X]]></category>
		<category><![CDATA[Imagick]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=77</guid>
		<description><![CDATA[I have now installed imagick on 3 machines running Apple OS X Lion and have put these instructions together to help others. There isn&#8217;t a great deal of information out there, well not a lot that seems to work or is complete. So here goes. The 3 machines I used are an iMac 27&#8243;, a [...]]]></description>
			<content:encoded><![CDATA[<p>I have now installed imagick on 3 machines running Apple OS X Lion and have put these instructions together to help others. There isn&#8217;t a great deal of information out there, well not a lot that seems to work or is complete. So here goes.</p>
<p>The 3 machines I used are an iMac 27&#8243;, a MBP and a Mac Mini all running OS X Lion with MAMP 2.0.5 and Xcode 4.2 installed</p>
<p>You are going to need the following software.</p>
<ol>
<li>Macports dmg http://www.macports.org/install.php</li>
<li>Latest version of PHP (At this time it is php5.3.10) http://www.php.net</li>
<li>Apple Xcode v4 or above</li>
</ol>
<p>If you have any problems please drop me a comment and I will do what I can to help out.</p>
<p>Now, on with the process. This is not a quick one so make sure you have time to do it and that your MBP (if using one) is mains powered.</p>
<p>1. Install Macports, that you have downloaded by running the dmg and installing via the pkg.</p>
<p>2. Open terminal and run
<pre class="brush: plain; title: ; notranslate">sudo port install ImageMagick</pre>
<p>3. Once this is complete run the following,
<pre class="brush: plain; title: ; notranslate">vi /Applications/MAMP/Library/bin/envvars</pre>
<p>4.  Comment out the following lines:</p>
<ul>
<li># DYLD_LIBRARY_PATH = &#8220;/Applications/MAMP/Library/lib: $DYLD_LIBRARY_PATH&#8221;</li>
<li># Export DYLD_LIBRARY_PATH</li>
</ul>
<p>5. Add this at the end</p>
<pre class="brush: plain; title: ; notranslate">export PATH=&quot;$PATH :/opt/local/bin&quot;</pre>
<p>6. Now create the directy to add the latest php version to.
<pre class="brush: plain; title: ; notranslate">mkdir /Applications/MAMP/bin/php/php5.3.6/include</pre>
<p>7. And change the permissions
<pre class="brush: plain; title: ; notranslate">sudo chmod -R 775 /Applications/MAMP/bin/php/php5.3.6/include/</pre>
<p>8. Download the php source code of the latest stable version of PHP 5 from <a href="http://php.net">php.net</a> if you haven&#8217;t already.</p>
<p>9. Navigate to the include folder you have just created
<pre class="brush: plain; title: ; notranslate">cd /Applications/MAMP/bin/php/php5.3.6/include/</pre>
<p>10. Navigate in to the include folder</p>
<p>11. Un tar the php file
<pre class="brush: plain; title: ; notranslate">tar -xvf /path/to/php-5.3.10.tar.gz</pre>
<p>12. Rename the file
<pre class="brush: plain; title: ; notranslate">mv php-5.3.10 php</pre>
<p>13. And navigate in to it
<pre class="brush: plain; title: ; notranslate">cd php</pre>
<p>14 Run the following to configure php
<pre class="brush: plain; title: ; notranslate">./configure</pre>
<p>15. Rename the current pear configuration file
<pre class="brush: plain; title: ; notranslate">mv /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf.original</pre>
<p>16. Install imagick
<pre class="brush: plain; title: ; notranslate">sudo pecl install imagick</pre>
<p>17. When asked for it type the imagickdirectory
<pre class="brush: plain; title: ; notranslate">/opt/local</pre>
<p>18. Add the following to the php.5.3.6 php.ini file via MAMP template editor
<pre class="brush: plain; title: ; notranslate">extension = imagick.so</pre>
<p>19. Navigate to the extensions folder to check if the imagick.so is there.
<pre class="brush: plain; title: ; notranslate">cd /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/</pre>
<p>If its not there then it needs to be copied from the location where it has installed. In my experience this could be in /opt/local or /usr/lib/php/extensions. Either way copy it over to the extensions folder in MAMP
<pre class="brush: plain; title: ; notranslate">cp /location/of/imagick.so /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/.</pre>
<p>You may also need to change the permissions on the recently copied file.
<pre class="brush: plain; title: ; notranslate">chmod 777 imagick.so</pre>
<p>Restart MAMP. Done!</p>
<p>Issues:</p>
<p>As I mentioned I had some issues when doing this, one has been covered off the other one was related to macports not working. At step 2 I received sudo: port: command not found. To overcome this you need to add the following to ~/.bash_history
<pre class="brush: plain; title: ; notranslate">export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info</pre>
<p>Now resource the .bash_profile
<pre class="brush: plain; title: ; notranslate">source .bash_profile</pre>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2012/02/install-imagick-on-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to set up a local git repository</title>
		<link>http://stevedurr.com/blog/2011/11/how-to-set-up-a-local-git-repository/</link>
		<comments>http://stevedurr.com/blog/2011/11/how-to-set-up-a-local-git-repository/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 10:02:10 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=71</guid>
		<description><![CDATA[In recent weeks I have become more involved with using git and github for version control. For my spare time projects I work on an iMac and a Mac Book Pro and I wanted a way to enable me to work on the same project on either machine. Setting up a local git repository was [...]]]></description>
			<content:encoded><![CDATA[<p>In recent weeks I have become more involved with using git and github for version control. For my spare time projects I work on an iMac and a Mac Book Pro and I wanted a way to enable me to work on the same project on either machine. Setting up a local git repository was the ideal route.</p>
<p>Now I know some will think why not just have an account with GitHub instead of going local? Well I didn&#8217;t want the expense or for these to publicly available. Also, I didn&#8217;t need one as I generally work on the same local network just on different machines.</p>
<p>Step 1 &#8211; The scenario<br />
As I said I work on an iMac and a MBP, both machines are running Lion, not that this has a baring on matters. I have a 250GB spare hard drive that I set up as a Time Machine back up disk some time back and thought this would be just the thing to house my projects. I enabled file sharing on both machines and ensured I could access each one from the other. To note the external drive I attached via usb to the iMac.</p>
<p>Step 2 &#8211; Remote setup<br />
The first step was to initialise git on the drive. This requires that you have the knowledge to install git on a mac, if not its easy, google it! To initialise git on the back up drive I found this the best way:</p>
<p>a) Open terminal (on mac) and navigate to the external drive. Create a folder for the project,
<pre class="brush: plain; title: ; notranslate">mkdir -p myproject</pre>
<p>b) Enter the folder and create a new folder called .git
<pre class="brush: plain; title: ; notranslate">mkdir -p .git</pre>
<p>c) Now enter this folder and run the following command
<pre class="brush: plain; title: ; notranslate">git --bare init</pre>
<p>You now have an empty git repository ready to be pushed to and pulled from.</p>
<p>Step 3 &#8211; Local setup<br />
We now need to set up the first instance of the project on one of the machines, the iMac will be first. Navigate your way using terminal to the project folder on the iMac, if you need to set it up you can use the same command as I used in step 2 part a. Enter this folder and run the git init command
<pre class="brush: plain; title: ; notranslate">git init</pre>
<p> You now have an empty repository. I am assuming here that you have a project ready to be pushed so the next part is to add all the files. At this point you can either add all the files or create a git ignore file. This is up to you depending on the project and which files you do not want to pass. Things like cache and log files are best to be ignored. To create the git ignore file run
<pre class="brush: plain; title: ; notranslate">vi .gitignore</pre>
<p> You can now add the folders and /or files here and save.</p>
<p>Step 4 &#8211; Adding the remote repo and project<br />
Before we add the files we need to add the remote repository on the external hard drive. Run
<pre class="brush: plain; title: ; notranslate">git remote add NAME /PATH/TO/EXTERNAL/DRIVE/REPO.git</pre>
<p> The name part here is what you want to call the repo, I generally use local for locally stored repos, makes sense. We are now ready to add the project, run
<pre class="brush: plain; title: ; notranslate">git add .</pre>
<p> and then commit using
<pre class="brush: plain; title: ; notranslate">git commit -am &quot;Add a comment here&quot;</pre>
<p>I appreciate there maybe other ways to do this, I am just using one method that I find works best for me.</p>
<p>Step 5 &#8211; Ready for the push.<br />
We are now ready to push the local files to the remote repo on the external drive. Run
<pre class="brush: plain; title: ; notranslate">git push NAME master</pre>
<p> We are using the master branch here, we haven&#8217;t yet created any branches so this is all we have. You will notice files being pushed to the local drive and once done we are ready to set up the other git repository on the second machine and pull to it.</p>
<p>Step 6 &#8211; Second machine<br />
This is fairly straight forward as all the steps have been done already so its a case of repeating them. On the 2nd machine follow these steps.<br />
a) navigate to the project folder and run the following commands
<pre class="brush: plain; title: ; notranslate">git init</pre>
<pre class="brush: plain; title: ; notranslate">git remote add NAME /PATH/TO/EXTERNAL/DRIVE/REPO.git</pre>
<p>1 And thats it.</p>
<p>Step 7 Notes<br />
it is worth remembering that if you have add files/folders to the .gitignore then these will need to be created. Some other projects I work on use systems such as Symfony2 and CS Cart which do have cache and logs that do not need to be kept so the folders which these are stored in are ignore and thus need to be created on all machines where the application is being developed.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/11/how-to-set-up-a-local-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac Book Pro freezes on start up</title>
		<link>http://stevedurr.com/blog/2011/08/mac-book-pro-freezes-on-start-up/</link>
		<comments>http://stevedurr.com/blog/2011/08/mac-book-pro-freezes-on-start-up/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 13:59:41 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Apple OS X]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=69</guid>
		<description><![CDATA[Ever since upgrading to Lion OS X from Snow Leopard my Mac Book Pro freezes on start up. When the login box appears the &#8220;waiting wheel&#8221; comes up and the whole machine is frozen. The only thing to do is hold down the pose button and restart. Looking at the Apple support site this seems [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since upgrading to Lion OS X from Snow Leopard my Mac Book Pro freezes on start up. When the login box appears the &#8220;waiting wheel&#8221; comes up and the whole machine is frozen. The only thing to do is hold down the pose button and restart.</p>
<p>Looking at the Apple support site this seems a common issue. I have a iMac 27&#8243; which also has the Lion upgrade on it with no issues.</p>
<p>Some suggestions lead to Adobe Flash player and disk permissions. Neither of these has solved the issue for me, some say it does but I have had no resolution to the issue.</p>
<p>The only thing so far that is working is to enter the password immediately when the box appears.</p>
<p>Lets hope Apple fix this soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/08/mac-book-pro-freezes-on-start-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No &#8220;File &gt; Save As&#8221; for native Apple apps on Lion OS X</title>
		<link>http://stevedurr.com/blog/2011/08/save-as-with-native-apple-apps-on-lion-os-x/</link>
		<comments>http://stevedurr.com/blog/2011/08/save-as-with-native-apple-apps-on-lion-os-x/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 18:00:44 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Lion]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=62</guid>
		<description><![CDATA[Something that has been bothering me with Apple&#8217;s new (awesome) OS X is the glaring lack of &#8220;Save As&#8221; in native apps like iWorks. This has caused some frustration I can tell you and will be doing for some others out there I&#8217;m sure. Don&#8217;t fear or give up, there is an option. Apple have [...]]]></description>
			<content:encoded><![CDATA[<p>Something that has been bothering me with Apple&#8217;s new (awesome) OS X is the glaring lack of &#8220;Save As&#8221; in native apps like iWorks.</p>
<p>This has caused some frustration I can tell you and will be doing for some others out there I&#8217;m sure. Don&#8217;t fear or give up, there is an option.</p>
<p>Apple have added the &#8220;Duplicate&#8221; function to the File menu, although this doesn&#8217;t have a short cut but it will create a copy of the current document. This can then be saved as a new document with a different/amended name in the location of your choice. Command S will see to that once the document has been duplicated.</p>
<p>Not as simple as &#8220;Save as&#8221; but still does the job.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/08/save-as-with-native-apple-apps-on-lion-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add nofollow to wordpress blogroll links</title>
		<link>http://stevedurr.com/blog/2011/06/add-nofollow-to-wordpress-blogroll-links/</link>
		<comments>http://stevedurr.com/blog/2011/06/add-nofollow-to-wordpress-blogroll-links/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 09:35:59 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=57</guid>
		<description><![CDATA[It seems there is a fair amount of posts on the subject of adding rel=&#8221;nofollow&#8221; to wordpress links already but the ones in my Google search were all for older versions and not for the latest version (WP v3.1.2) so I thought I would update the situation. Locate the file &#8220;bookmark-template.php&#8221; in the wp-includes folder. [...]]]></description>
			<content:encoded><![CDATA[<p>It seems there is a fair amount of posts on the subject of adding rel=&#8221;nofollow&#8221; to wordpress links already but the ones in my Google search were all for older versions and not for the latest version (WP v3.1.2) so I thought I would update the situation.</p>
<p>Locate the file &#8220;bookmark-template.php&#8221; in the wp-includes folder. The line you require is around the 99 mark if the file is previously unedited. Look for:</p>
<pre class="brush: php; title: ; notranslate">
$output .= '&lt;a href=&quot;' . $the_link . '&quot;' . $rel . $title . $target . '&gt;';
</pre>
<p>All you need to do is add the rel=&#8221;nofollow&#8221;</p>
<pre class="brush: php; title: ; notranslate">
$output .= '&lt;a href=&quot;' . $the_link . '&quot;' . $rel . $title . $target . 'rel=&quot;nofollow&quot;&gt;';
</pre>
<p>NOTE:<br />
Ensure you have all rel options in the link settings set to none. This seem to override this setting.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/06/add-nofollow-to-wordpress-blogroll-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to clear the dns cache on Mac OS X</title>
		<link>http://stevedurr.com/blog/2011/06/how-to-clear-the-dns-cache-on-mac-os-x/</link>
		<comments>http://stevedurr.com/blog/2011/06/how-to-clear-the-dns-cache-on-mac-os-x/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 19:33:54 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=49</guid>
		<description><![CDATA[On occasions you may be required to clear your dns cache on you mac. This is a simple task and only requires one of 2 commands and access t Terminal. Locate terminal in the Applications->Utilities folder. Once the app is open you need to enter one of the following commands. The command is ependant upon [...]]]></description>
			<content:encoded><![CDATA[<p>On occasions you may be required to clear your dns cache on you mac. This is a simple task and only requires one of 2 commands and access t Terminal.</p>
<p>Locate terminal in the Applications->Utilities folder. Once the app is open you need to enter one of the following commands. The command is ependant upon the version of OS X you are running. If you are upto date and are running OS X 10.5 or above you need to enter this on the command line:</p>
<pre class="brush: php; title: ; notranslate">
dscacheutil -flushcache
</pre>
<p>If you are running OS X 10.4 or below then enter this on the command line:</p>
<pre class="brush: php; title: ; notranslate">
lookupd -flushcache
</pre>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/06/how-to-clear-the-dns-cache-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Light of the World</title>
		<link>http://stevedurr.com/blog/2011/06/the-light-of-the-world/</link>
		<comments>http://stevedurr.com/blog/2011/06/the-light-of-the-world/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 14:16:40 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[sunset]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=31</guid>
		<description><![CDATA[<img class="aligncenter size-thumbnail wp-image-30" title="The Light of the World" src="http://stevedurr.com/blog/wp-content/uploads/2011/06/whitby-june-2011-150x150.jpg" alt="Sun setting through an old street lamp" width="150" height="150" /><br />The sun setting in Whitby, England. Taken whilst on holiday with my girlfriend Jessica in June 2011.]]></description>
			<content:encoded><![CDATA[<p><a href="http://stevedurr.com/blog/wp-content/uploads/2011/06/whitby-june-2011.jpg"><img class="size-medium wp-image-30 aligncenter" title="The Light of the World" src="http://stevedurr.com/blog/wp-content/uploads/2011/06/whitby-june-2011-263x300.jpg" alt="Sunseting through an old street lamp" width="263" height="300" /></a></p>
<p>The sun setting in Whitby, England. Taken whilst on holiday with my girlfriend Jessica in June 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/06/the-light-of-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New website</title>
		<link>http://stevedurr.com/blog/2011/05/new-website/</link>
		<comments>http://stevedurr.com/blog/2011/05/new-website/#comments</comments>
		<pubDate>Mon, 30 May 2011 11:32:37 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://stevedurr.com/blog/?p=25</guid>
		<description><![CDATA[I have just uploaded my new portfolio website. The site is to be a central location for all my technical creations and musings. Having had a few portfolio websites and blogs I have now found the time to finally create something new and in one place. I am in the process of adding my old [...]]]></description>
			<content:encoded><![CDATA[<p>I have just uploaded my new portfolio website. The site is to be a central location for all my technical creations and musings. Having had a few portfolio websites and blogs I have now found the time to finally create something new and in one place.</p>
<p>I am in the process of adding my old blog posts to this site form my old blogs, stevedurr.co.uk and stephendurr.com. keep checking back for updates or subscribe to the feed.</p>
<p>Thanks</p>
<p>Steve</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/05/new-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Short Hand Font Tag</title>
		<link>http://stevedurr.com/blog/2011/05/css-short-hand-font-tag/</link>
		<comments>http://stevedurr.com/blog/2011/05/css-short-hand-font-tag/#comments</comments>
		<pubDate>Sat, 21 May 2011 18:10:07 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Font]]></category>

		<guid isPermaLink="false">http://stevedurr/blog/?p=5</guid>
		<description><![CDATA[Up until now I have never bothered with the css font shorthand attribute, always opting to use the individual attributes instead, solely due to my lack of understanding of how it is structured. After coming across it in some web updates I have recently completed I decided to investigate and understand what it all means. [...]]]></description>
			<content:encoded><![CDATA[<p>Up until now I have never bothered with the css font shorthand attribute, always opting to use the individual attributes instead, solely due to my lack of understanding of how it is structured. After coming across it in some web updates I have recently completed I decided to investigate and understand what it all means.</p>
<p>The css font tag looks more baffling than other css shorthand tags, take the border tag for example:</p>
<pre class="brush: css; collapse: false; first-line: 1; gutter: true; highlight: [1]; title: ; notranslate">
border : 1px solid #000;
</pre>
<p>A 1 pixel solid black border, easy. Now take the font tag shorthand..</p>
<pre class="brush: css; collapse: false; first-line: 1; gutter: true; highlight: [1]; title: CSS Font Tag Breakdown; notranslate">
font: italic small-caps bold 12px/18px Verdana, Arial, serif;
</pre>
<p>What on Earth is that all about&#8230; Well, if we break it up we see that we have:</p>
<p>Style, Variant, Weight, Size / Line Height and Family.</p>
<p>The first 3 aspects, Style, Variant and Weight are all optional as is the line height. If line height is omitted then so is the forward slash that splits size and line height. The family must always come last and along with the size is mandatory.</p>
<p>I had no idea it was that simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/05/css-short-hand-font-tag/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP and mySQL dates</title>
		<link>http://stevedurr.com/blog/2011/03/php-and-mysql-dates/</link>
		<comments>http://stevedurr.com/blog/2011/03/php-and-mysql-dates/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 18:21:45 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[functions]]></category>

		<guid isPermaLink="false">http://stevedurr/blog/?p=7</guid>
		<description><![CDATA[Normally this is not an issue but a recent project I was working on meant that the normal way of using dates has caused an issue. When converting a date that is formatted dd/mm/yyyy to yyyy-mm-dd hh:mm:ss didn&#8217;t work the way I wanted it to. A way round this is to format the UK date [...]]]></description>
			<content:encoded><![CDATA[<p>Normally this is not an issue but a recent project I was working on meant that the normal way of using dates has caused an issue. When converting a date that is formatted <strong>dd/mm/yyyy</strong> to <strong>yyyy-mm-dd hh:mm:ss</strong> didn&#8217;t work the way I wanted it to. A way round this is to format the UK date in to the US date format then in to the mySQL datetime format and of course vice-versa on retrieving the date from the database.</p>
<h2>Here&#8217;s how</h2>
<p>I created 2 functions, php_to_mysql() and mysql_to_php</p>
<p><strong>PHP to mySQL</strong></p>
<pre class="brush: php; title: ; notranslate">
function phptomysql($php)
{
	//Break the date up in to an array
	$php = explode(&quot;/&quot;, $php);
	//Re=arrange the date in to the US format
	$php = $php[1] . &quot;/&quot; . $php[0] . &quot;/&quot; . $php[2];
	//Convert the date (string) in to php time format
	$php = strtotime($php);
	//Format the time value in to a php variable in the format of mySQL datetime field
	$php = date('Y-m-d H:i:s', $php);
	return $php;
}</pre>
<p><strong>mySQL to PHP</strong></p>
<pre class="brush: php; title: ; notranslate">function mysqltophp($mysql)
	{
		//Change the mySQL date to a time value.
		$mysql = strtotime($mysql);
		//Format the time value to the UK date format
		$mysql = date(&quot;d/m/Y&quot;, $mysql);
		return $mysql;
	}
</pre>
<p>This one is much simplier. As we do not need to involve a re-arrangment of the date from US to UK, we can just format the time value to the UK format straight off.</p>
<h2>Example</h2>
<p><a href="http://www.stevedurr.com/snippets/php/dates/date-formatting.php" title="PHP date formatting by Steve Durr">View the date formatting in operation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://stevedurr.com/blog/2011/03/php-and-mysql-dates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

