<?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"
	>

<channel>
	<title>4o3.net</title>
	<atom:link href="http://4o3.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://4o3.net</link>
	<description>An Irish man's adventures in Web Development</description>
	<pubDate>Fri, 04 Jul 2008 19:53:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>State of the nation: Small Irish Web Development Agencies</title>
		<link>http://4o3.net/2008/07/04/state-of-the-nation-small-irish-web-development-agencies/</link>
		<comments>http://4o3.net/2008/07/04/state-of-the-nation-small-irish-web-development-agencies/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 16:45:47 +0000</pubDate>
		<dc:creator>Ian McCarthy</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://4o3.net/?p=5</guid>
		<description><![CDATA[I have spent the last 6 years working for small web development agencies (Commonly places that do both web and print) and they all, and all the places I have delt with as a result have not taken anything on board from PHP5. You could drop them on a PHP4 server and their code would [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent the last 6 years working for small web development agencies (Commonly places that do both web and print) and they all, and all the places I have delt with as a result have not taken anything on board from PHP5. You could drop them on a PHP4 server and their code would run just as happily. They do not use any of the benifits that PHP5 has given them. About all that has changed is they have lost their reliance on register_globals. Why is this?</p>
<p><span id="more-5"></span></p>
<p>In my opinion, both from my own experience and from talking to other developers in the same world as I am there are a number of reasons.</p>
<ol>
<li><strong>The comfort zone :</strong> This is first and foremost amongst all reasons. This has been seen time and time again during the end of life of any development platform. Many people when faced with the fact that they should change the way they work, that they should evolve their skill set, they will shy away. They will make excuses like &#8220;I don&#8217;t have the time to learn PHP5&#8243; and &#8220;But I already have loads of functions written for PHP4.</li>
<li><strong>The cheap hosting market: </strong>Ireland&#8217;s market leader in the hosting market is register365. In fact this website is hosted with register 365. As far as their shared servers go (Which is where most small web development firms will be hosting) the majority of the Linux ones are still running PHP4 (As of the last time I was able to check, which was little over a month ago). Their PHP5 servers are not up capable of running the frameworks and librarys that the foremost PHP sites tell us to run (A prime example would be the apparent lack of anything but SqLite drivers enabled for the PDO extention). Of course they have their reasons for this. There are thousands of sites hosted on them by paying customers that may not function if they were to upgrade.</li>
<li><strong>The state of the market: </strong>To by honest, why should they upgrade? They will be more skilled developers afterwards, but in the small web development market their is little incentive to improve in this way. Their pay is unlikely to increase, they are likely to have to learn to do this in their own time. While becoming a better programmer in theory opens up more employment oppertunities to them, alot of them work in small firms in the first place because they either do not want to (or can not) work in a city. This could be due to family comitments or any number of other reasons.</li>
</ol>
<p><strong>What can be done about this?</strong></p>
<p>There are a couple of approaches to dealing with this. The first and foremost is to remove the learning curve. When a PHP4 developer opens up any of the popular php blogs he is faced with things like MVC and expansive frameworks. He is bombarded with things like test driven development.  How can this be delt with better by people looking to improve the development community in Ireland?</p>
<p>Take simple real world examples with a shallow learning curve that would apply directly to the small studio developer. For example, you may demonstrate how we can write a class for dealing with contact form submissions. How this can enable us to fully re-use code rather than the simple &#8216;Copy/Paste/Edit&#8217; that goes on with most developers. Then you may demonstrate how using OO concepts like inheritence or interfaces you can enable this class to stick the information directly into a database, or send it via SMS. Work up from there.</p>
<p>The other thing that needs to be addressed is the hosting market. But maybe this has been addressed by someone already. Do any of the Irish hosting providers offer a low price PHP5 enviroment (With the relevant trimmings) in either a domian by domain or a reseller basis?</p>
<p>Please give me your opinions on this.</p>
<p><em>This post has been updated to reflect Stephens comment that the non-dedicated accounts that were with hosting365 are now controlled by register365 and that part of the company was bought out during the year.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://4o3.net/2008/07/04/state-of-the-nation-small-irish-web-development-agencies/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Mysql date functions</title>
		<link>http://4o3.net/2008/06/29/using-mysql-date-functions/</link>
		<comments>http://4o3.net/2008/06/29/using-mysql-date-functions/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 07:49:11 +0000</pubDate>
		<dc:creator>Ian McCarthy</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[date]]></category>

		<category><![CDATA[date_format]]></category>

		<category><![CDATA[functions]]></category>

		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://4o3.net/?p=4</guid>
		<description><![CDATA[This is something that slipped by me for a long time.
Like many other developers I know, I have written a function that takes a date from mysql (In any of the relevant formats, usually datetime though) and then formats it (Using substr() or strtotime() and date()) with PHP into a nice human readable format for [...]]]></description>
			<content:encoded><![CDATA[<p>This is something that slipped by me for a long time.</p>
<p>Like many other developers I know, I have written a function that takes a date from mysql (In any of the relevant formats, usually datetime though) and then formats it (Using <a href="http://www.php.net/substr" target="_blank">substr()</a> or <a href="http://www.php.net/strtotime" target="_blank">strtotime()</a> and <a href="http://www.php.net/date" target="_blank">date()</a>) with PHP into a nice human readable format for display on the website.</p>
<p>There is a more elegant solution however.</p>
<p><span id="more-4"></span></p>
<p>MySQL has a number of functions in place for dealing with <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html" target="_blank">dates and times</a> so you can return the nicely formatted date direct from the database!</p>
<p>Most importantly for this example we have DATE_FORMAT.</p>
<p>In your database, you have a table `news_stories` that has a field `date` with a type of &#8216;date&#8217;</p>
<pre name="code" class="sql">
SELECT DATE_FORMAT(date, &#039;%M %D, %Y&#039;) FROM `news_stories` WHERE 1
</pre>
<p>This will return a nice easy to read date (Such as 29th June, 2008) in your result set.</p>
<pre class="programlisting">
</pre>
]]></content:encoded>
			<wfw:commentRss>http://4o3.net/2008/06/29/using-mysql-date-functions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How do I find the date a week starts given the week number</title>
		<link>http://4o3.net/2008/06/25/how-do-i-find-the-date-a-week-starts-given-the-week-number/</link>
		<comments>http://4o3.net/2008/06/25/how-do-i-find-the-date-a-week-starts-given-the-week-number/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 18:18:20 +0000</pubDate>
		<dc:creator>Ian McCarthy</dc:creator>
		
		<category><![CDATA[php]]></category>

		<category><![CDATA[date]]></category>

		<category><![CDATA[week number]]></category>

		<guid isPermaLink="false">http://4o3.net/?p=3</guid>
		<description><![CDATA[I came accross this problem recently while developing a time tracking application.
Typically, I have found that when viewing timesheets people prefer to be able to see the week at a glance. For this reason I will normally store them in a database with three int (day (From 1-7), Week (From 1-53) and year (From 0001 [...]]]></description>
			<content:encoded><![CDATA[<p>I came accross this problem recently while developing a time tracking application.</p>
<p>Typically, I have found that when viewing timesheets people prefer to be able to see the week at a glance. For this reason I will normally store them in a database with three int (day (From 1-7), Week (From 1-53) and year (From 0001 to 9999)). This allows me to easilly pull a two dimensional array from the database for output into the virtual timesheet</p>
<p><span id="more-3"></span></p>
<pre name="code" class="sql">
SELECT * FROM `timesheet` WHERE `week`=26 AND `year`=2008 ORDER BY `day` ASC, `start_time` ASC
</pre>
<p>Now, this is all well and good, and it&#8217;s fine for most of us. But generally a customer will want to see something along the lines of:</p>
<p><strong>Timesheet for week beginning 23rd of June 08</strong></p>
<p>This also makes it much easier from a useability perspective when displaying monthly or annual views. If you are looking to track down a timesheet for last Feburary, it&#8217;s easier to jump to it if you are looking at it by date rather than by number.</p>
<p>Looking at the php date related functions, there is no real obvious way to handle this. But it can be done.</p>
<p>The international standards for dealing with dates and times are covered by ISO 8601, and <a href="http://en.wikipedia.org/wiki/ISO_8601" target="_blank">here is an easy to understand wikipedia article on it</a>.</p>
<p>So if you take a look at the week dates part of it, it gives us some mutually equivalent definitions for week 01</p>
<ul>
<li>the week with the year&#8217;s first Thursday in it.</li>
<li>the week with 4 January in it.</li>
<li>the first week with the majority (four or more) of its days in the starting year.</li>
<li>the week starting with the Monday in the period 29 December – 4 January.</li>
</ul>
<p>So, the easiest way to work with this from PHP, is to find out what date Jan 4th + $week_number weeks is. Assuming your current week number is stored in the variable $week, and the current year is stored in the variable $year this can be done as follows.</p>
<pre name="code" class="php">
$time = strtotime($year . &#039;0104 +&#039; . ($week - 1) . &#039; weeks&#039;);
</pre>
<p><a href="http://ie2.php.net/strtotime" target="_blank">strtotime()</a> is a very handy function that allows you to turn a variety of human readable date formats into unix timestamps. As you can see above it also allows you to preform additions and subtractions on it.</p>
<p>To breakdown that line, what I am doing is getting the timestamp for the 4th of January this year + this week (less 1) weeks. The reason I subtract 1 up above is because January 4th is in week 1, not week 0.</p>
<p>So now we have a date in this week, but it&#8217;s not nesecerally the monday. But that&#8217;s fairly easy to find out from here with the following line.</p>
<pre name="code" class="php">
$mondayTime = strtotime(&#039;-&#039; . (date(&#039;w&#039;, $time) - 1) . &#039; days&#039;, $time);
</pre>
<p>All I am doing there is saying &#8220;Give me a timestamp for this date - (However many days we are past monday) days.&#8221;.</p>
<p>So now we have our timestamp for the monday of the relevant week. So let&#8217;s clean it up a bit and stick it in a function.</p>
<pre name="code" class="php">
function getWeekStartDate($week, $year, $format = &#039;dS F, Y&#039;) {
        $time = strtotime($year . &#039;0104 +&#039; . ($week - 1) . &#039; weeks&#039;);
        $mondayTime = strtotime(&#039;-&#039; . (date(&#039;w&#039;, $time) - 1) . &#039; days&#039;, $time);
        return date($format, $mondayTime);
 }
</pre>
<p>Now, all I have done here is added in functionality to get it to return a nice easy to read date. Just pass it the exact same formatting you would send to the php <a href="http://ie2.php.net/date" target="_blank">date()</a> function.</p>
<p>Hope this helps someone out there!</p>
]]></content:encoded>
			<wfw:commentRss>http://4o3.net/2008/06/25/how-do-i-find-the-date-a-week-starts-given-the-week-number/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
