<?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>Open Script Solution&#187; function</title>
	<atom:link href="http://www.openscriptsolution.com/tag/function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.openscriptsolution.com</link>
	<description>... where solutions for script programming are found ...</description>
	<lastBuildDate>Tue, 31 Jan 2012 03:22:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Know The Number of Days from Monday until Today of This Week in PHP</title>
		<link>http://www.openscriptsolution.com/2009/12/13/how-to-know-the-number-of-days-from-monday-until-today-of-this-week-in-php/</link>
		<comments>http://www.openscriptsolution.com/2009/12/13/how-to-know-the-number-of-days-from-monday-until-today-of-this-week-in-php/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 16:26:49 +0000</pubDate>
		<dc:creator>Masino Sinaga</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[day]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Monday]]></category>
		<category><![CDATA[number of days]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[today]]></category>
		<category><![CDATA[week]]></category>

		<guid isPermaLink="false">http://www.openscriptsolution.com/?p=1025</guid>
		<description><![CDATA[There was a question asked to myself how to know the number of days that calculated from Monday until today of this week by using PHP script. Well, actually, we can make a function by checking based on the day name of today, then return the value based on its day name to the function. [...]]]></description>
			<content:encoded><![CDATA[<p>There was a question asked to myself how to know the number of days that calculated from Monday until today of this week by using PHP script. Well, actually, we can make a function by checking based on the day name of today, then return the value based on its day name to the function. So here is the solution I made. <span id="more-1025"></span></p>
<p>Create a php file named <strong>daysnumber.php</strong>, and copy-paste this following code into it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @author Masino Sinaga, http://www.openscriptsolution.com
 * @copyright December 13, 2009
 */</span>
&nbsp;
<span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> DaysNumberStartedFromMondayUntilTodayThisWeek<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'The number of days from Monday until today is &lt;b&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$days</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/b&gt; day(s).'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> DaysNumberStartedFromMondayUntilTodayThisWeek<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
  <span style="color: #000088;">$dayname</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'D'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dayname</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Sun'</span><span style="color: #339933;">:</span>
	  <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> 
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Mon'</span><span style="color: #339933;">:</span>
          <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Tue'</span><span style="color: #339933;">:</span>
	  <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Wed'</span><span style="color: #339933;">:</span>
	  <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Thu'</span><span style="color: #339933;">:</span>
	  <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
  	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Fri'</span><span style="color: #339933;">:</span>
          <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
	  <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'Sat'</span><span style="color: #339933;">:</span>
          <span style="color: #000088;">$days</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$days</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.openscriptsolution.com%2F2009%2F12%2F13%2Fhow-to-know-the-number-of-days-from-monday-until-today-of-this-week-in-php%2F&amp;title=How%20to%20Know%20The%20Number%20of%20Days%20from%20Monday%20until%20Today%20of%20This%20Week%20in%20PHP" id="wpa2a_2"><img src="http://www.openscriptsolution.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.openscriptsolution.com/2009/12/13/how-to-know-the-number-of-days-from-monday-until-today-of-this-week-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
