<?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>devexp &#187; day</title>
	<atom:link href="http://www.devexp.eu/tag/day/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devexp.eu</link>
	<description>DEVelopment EXPerience, shared with the world!</description>
	<lastBuildDate>Tue, 16 Feb 2010 14:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>conversion of dates</title>
		<link>http://www.devexp.eu/2009/03/06/conversion-of-dates/</link>
		<comments>http://www.devexp.eu/2009/03/06/conversion-of-dates/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 08:06:13 +0000</pubDate>
		<dc:creator>van Rumste Kenneth</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[day]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[week]]></category>
		<category><![CDATA[year]]></category>

		<guid isPermaLink="false">http://www.devexp.eu/?p=391</guid>
		<description><![CDATA[I struggled with a bit of code last week, but found a nice solution. The goal was to convert 3 parameters into a date: 1. The day of the week (0 -&#62; 6, 0 = Monday, 1 = Tuesday, 2 = Wednesday, etc.) 2. The week number (0 – 53, see our previous post for [...]]]></description>
			<content:encoded><![CDATA[<p>I struggled with a bit of code last week, but found a nice solution.</p>
<p>The goal was to convert 3 parameters into a date:</p>
<p>1. The day of the week (0 -&gt; 6, 0 = Monday, 1 = Tuesday, 2 = Wednesday, etc.)<br />
2. The week number (0 – 53, <a title="windows bug in week numbers" href="http://www.devexp.eu/?p=385" target="_self">see our previous post for more info</a>)<br />
3. And the year (2009)</p>
<p>Well in this function we got to that result.</p>
<pre class="brush: php;">
/**
* create datetime from dow, week number and year
* @param integer $dow (MUST BE 0 -&gt; 6)
* @param integer $weekNumber
* @param integer $year
* @return datetime
*/
public function getDateTimeByDowWeekYear ($dow, $weekNumber, $year) {
// get the first day of the current year, according iso standards
$offset = date('w', mktime(0,0,0,1,1,$year));
$offset = ($offset &lt; 5) ? 1-$offset : 8-$offset;
//get the first Monday of the year
$monday = mktime(0,0,0,1,1+$offset,$year);
//add the number of weeks
$mondayTime = strtotime('+' . ($weekNumber - 1) . ' weeks', $monday);
// add the number of weekdays
$dayTime = strtotime('+' . $dow . ' days', $mondayTime);
//create a date
return date('Y-m-d H:i:s',$dayTime);
}
</pre>
<p>It seemed to be a lot easier then I thought.<br />
Et voila, have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devexp.eu/2009/03/06/conversion-of-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
