
<?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>jtGraphic.net &#187; Function Friday</title>
	<atom:link href="http://jtgraphic.net/tag/function-friday/feed/" rel="self" type="application/rss+xml" />
	<link>http://jtgraphic.net</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 01:15:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>PHP Function Friday: date</title>
		<link>http://jtgraphic.net/php-function-friday-date/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-function-friday-date</link>
		<comments>http://jtgraphic.net/php-function-friday-date/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 04:02:01 +0000</pubDate>
		<dc:creator>jt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[Function Friday]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=445</guid>
		<description><![CDATA[<p>Tweet I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can do some pretty cool things like calculate this date from that date, make a calendar, or store information about &#8230; <a href="http://jtgraphic.net/php-function-friday-date/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-date/">PHP Function Friday: date</a></p>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-date%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-date/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-date/"  data-text="PHP Function Friday: date" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-date/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-date/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I think the date function is extremely useful.  It gives your programs an awareness of WHEN they are.  You can do some pretty cool things like calculate this date from that date, make a calendar, or store information about when an action was taken.</p>
<h3>Function and Syntax</h3>
<pre>string date(string $format  [, int $timestamp  ])</pre>
<h3>Manual Entry</h3>
<p><a href="http://php.net/manual/en/function.date.php" target="_blank">http://php.net/manual/en/function.date.php</a></p>
<h3>Notes and Use</h3>
<p>There are two variables you can pass to the date function: the string format, and the timestamp.  What are those?  The string format uses various characters to define how the string the function returns will be formatted.  The table for which characters mean what is on the <a href="http://php.net/manual/en/function.date.php">PHP Manual Page</a>.  The timestamp is a Unix timestamp for a specific date/time.</p>
<h3>Other Functions Referenced in Examples</h3>
<ul>
<li><a href="http://php.net/manual/en/control-structures.if.php" target="_blank">if<br />
</a></li>
</ul>
<h3>Examples</h3>
<h4>Output Today&#8217;s Date and Time</h4>
<p>This should just simply output today&#8217;s date.  I did a few formats based on January 1, 2009 at 4:52:39 PM.</p>
<pre>echo date("Y-m-d H:i:s"); /* Should output '2009-01-01 16:52:39'.  Common programming format*/
echo date("F n, Y at g:m:s A") /* Should output 'January 1, 2009 at 4:52:39 PM'.*/
</pre>
<h4>Put a Message on Your Website Every Monday</h4>
<p>Do you hate Mondays?  Let everyone know.  This script checks to see if it&#8217;s Monday and then outputs a message if it is.  That &#8216;w&#8217; in the date function is a numeric representation of the day of the week.  For instance: Wednesday is 3 and Sunday is 0.</p>
<pre>if(date("w") == 1) {
   echo "Ugh.  It's Monday."
}
</pre>
<h3>Examples Elsewhere on this Site:</h3>
<p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" target="_blank">Holiday Notices</a></p>
<h3>Conclusion</h3>
<p>Date functions are extremely useful when trying to figure out when you are (or better stated: when your program tries to figure out when it is).  Using date and time functions allow you to create a lot of automation in your scripts.  Have you got any useful implementations on this function?</p>
<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-date%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-date/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-date/"  data-text="PHP Function Friday: date" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-date/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-date/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-date/">PHP Function Friday: date</a></p>]]></content:encoded>
			<wfw:commentRss>http://jtgraphic.net/php-function-friday-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Function Friday: include</title>
		<link>http://jtgraphic.net/php-function-friday-include/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-function-friday-include</link>
		<comments>http://jtgraphic.net/php-function-friday-include/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 21:52:28 +0000</pubDate>
		<dc:creator>jt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Function Friday]]></category>
		<category><![CDATA[include]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=421</guid>
		<description><![CDATA[<p>Tweet Including files makes it really easy to NOT duplicate code. It&#8217;s great for creating headers and footers for websites, or using it in the inverse: make the header and footer in one file, and include the content.  You can &#8230; <a href="http://jtgraphic.net/php-function-friday-include/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-include/">PHP Function Friday: include</a></p>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-include%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-include/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-include/"  data-text="PHP Function Friday: include" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-include/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-include/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Including files makes it really easy to NOT duplicate code.  It&#8217;s great for creating headers and footers for websites, or using it in the inverse: make the header and footer in one file, and include the content.  You can also store site configuration files, functions, and repeating content, etc.</p>
<h3>Function and Syntax</h3>
<pre>include(&lt;file path&gt;);
</pre>
<h3>Manual Entry</h3>
<p><a href="http://php.net/manual/en/function.include.php">http://php.net/manual/en/function.include.php</a></p>
<h3>Notes and Use</h3>
<p>Includes are a great way to include the same code to many different PHP files.  I find this the most useful for storing variables and functions across an entire website.  The other great way to use this function is to include repetitive code that needs to be outside of a function scope &#8211; for example: including form layouts across multiple pages.  I like to use the same include for both my add and edit pages on a form sometimes.</p>
<h3>Examples</h3>
<h4>Storing Site-Wide Variables</h4>
<p>This is stored in the file &#8216;configuration.php&#8217;:</p>
<pre>$blog_name = "jtGraphic.net";
$blog_description = "Ramblings of an Internet Addict";
</pre>
<p>This is another PHP file where you&#8217;re calling the include &#8211; call it whatever you want.  I&#8217;ll call mine &#8216;main.php&#8217;:</p>
<pre>include("configuration.php");
echo $blog_name."&lt;br /&gt;";
echo $blog_description;
</pre>
<p>This is another PHP file somewhere else on the site &#8211; maybe inside the /content/ directory.  Call it whatever you want.  I&#8217;ll call mine &#8216;content.php&#8217;:</p>
<pre>include("../configuration.php");
echo $blog_name."&lt;br /&gt;";
echo $blog_description;
</pre>
<p>Both &#8216;main.php&#8217; and &#8216;content.php&#8217; will echo out the same information because you included the same file at the beginning of each.</p>
<h4>Website Header and Footer</h4>
<p>I find that another extremely powerful use of includes is to build your header and footer for your website.  In this example, we&#8217;re going to dynamically set the title variable in the main content page and call it inside the include.  This is how I build some of my simpler sites.  By the way, this isn&#8217;t HTML standards compliant.  It&#8217;s just an example.</p>
<p>We&#8217;ll call this file &#8216;header.php&#8217;</p>
<pre>&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;jtGraphic.net &lt;?php echo $page_title; ?&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
/*snip*/
</pre>
<p>We&#8217;ll call this next file &#8216;footer.php&#8217;;</p>
<pre>//snip
      &lt;div&gt; &amp;copy; James Thompson and jtGraphic.net &lt;/div&gt;
   &lt;body&gt;
&lt;/html&gt;
</pre>
<p>Now that we have our header and footer, we can make some more pages:</p>
<p>We&#8217;ll call this one &#8216;content_1.php&#8217;:</p>
<pre>$page_title = "Some Title";
include("header.php");
//content here
include("footer.php");
</pre>
<p>We&#8217;ll call the next one &#8216;content_2.php&#8217;:</p>
<pre>$page_title = "Some Other Title";
include("header.php");
//content here
include("footer.php");
</pre>
<p>When accessing &#8216;content_1.php&#8217; and &#8216;content_2.php&#8217; you should get everything you put in &#8216;header.php&#8217; and &#8216;footer.php&#8217;, but the title should be what you defined in the content files.  This is a really rudimentary example, but it is VERY useful.</p>
<h3>Conclusion</h3>
<p>So, remember: whenever you have a set of code that is duplicated you can probably deal with it through <a href="http://www.jtgraphic.net/2009/09/php-function-friday-function/" target="_blank">custom functions</a> or includes.  Don&#8217;t duplicate the code!  If you have your own examples, feel free to link them up below!</p>
<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-include%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-include/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-include/"  data-text="PHP Function Friday: include" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-include/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-include/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-include/">PHP Function Friday: include</a></p>]]></content:encoded>
			<wfw:commentRss>http://jtgraphic.net/php-function-friday-include/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Function Friday: function</title>
		<link>http://jtgraphic.net/php-function-friday-function/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-function-friday-function</link>
		<comments>http://jtgraphic.net/php-function-friday-function/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 00:29:43 +0000</pubDate>
		<dc:creator>jt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Function Friday]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[strtotime]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.jtgraphic.net/?p=368</guid>
		<description><![CDATA[<p>Tweet So, I&#8217;ve decided to start including a new post every Friday &#8211; kind of as a discipline thing. I&#8217;m going to write a post on a PHP function every Friday. I&#8217;m not just going to regurgitate the post in &#8230; <a href="http://jtgraphic.net/php-function-friday-function/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-function/">PHP Function Friday: function</a></p>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-function%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-function/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-function/"  data-text="PHP Function Friday: function" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-function/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-function/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>So, I&#8217;ve decided to start including a new post every Friday &#8211; kind of as a discipline thing.  I&#8217;m going to write a post on a PHP function every Friday.  I&#8217;m not just going to regurgitate the post in the official PHP manual, but I&#8217;m going to list my experience with it along with some creative ways to use it.</p>
<p>With out any further adieu, I&#8217;m posting on the first official building block (which isn&#8217;t technically a function, but I digress) &#8216;function&#8217;:</p>
<h3>PHP Function and Syntax</h3>
<pre>function <em>&lt;function name&gt;</em>(<em>&lt;parameters&gt;</em>) {
   /*add code here*/
}
</pre>
<h3>PHP Manual Entry</h3>
<p>Check here for version information, or anything I may have missed:</p>
<p><a href="http://www.php.net/manual/en/functions.user-defined.php" target="_blank">http://www.php.net/manual/en/functions.user-defined.php</a></p>
<h3>Notes and Use</h3>
<p>This is great for building blocks of code that you repeat a lot.  I like to use it when duplicating XML/HTML code, such as links or form elements, which I will outline below.  Functions, both custom and built in, are the primary building blocks of a good program.  Everything else is just procedural.</p>
<p>Also, on a side note: <a href="http://svn.php.net/viewvc/php/php-src/trunk/CODING_STANDARDS?view=co" target="_blank">PHP Coding Standards</a> is a good read if you&#8217;re really geeky.</p>
<p>An important thing to keep in mind about making custom functions is that someone has probably already made it if it doesn&#8217;t already exist in the built in functions for PHP.  Feel free to jump online and see if someone has already made a function to do what you&#8217;re trying to do.  I like to use the site <a href="http://www.hotscripts.com/" target="_blank">HotScripts.com</a>, which has both free and commercial PHP scripts available.  Chances are: if I need it, they have it.  It saves me a ton of time.</p>
<p>Note in the examples that I precede the function with some explanation of what it does, the author, etc.  This isn&#8217;t needed, but it&#8217;s a REALLY good habit.</p>
<h4>Other Functions Referenced in Examples</h4>
<ul>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">date()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">strtotime()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">time()</a></li>
<li><a href="http://php.net/manual/en/function.return.php" target="_blank">return()</a></li>
</ul>
<h3>Examples</h3>
<p>Here&#8217;s the meat.  Let&#8217;s make some stuff work.</p>
<h4>Creating Image Links</h4>
<pre>/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  This function is for displaying image links in HTML.  It's less typing,
 *  and easier to remember what needs to be slashed out.  An image
 *  with the same name as the file name of the page you're linking to needs to
 *  be placed on the server in the same path as the internal variable
 *  '$image_path' and the same extension as '$image_ext'.
 *
 *  Arguments
 *  ------------------------------------
 *  $url - URL of the link
 *  $extra_tag_html - this is any extra HTML, like class, id, or style
 *
 */

/* Build the function. */

	function create_html_link($name, $extra_tag_html) {
		/* Define internal variables. */
			$image_path = "images/";
			$image_ext   = ".jpg";

		/* Output the HTML. */
			echo
				"&lt;a href="".$name.".php" ".$extra_tag_html."&gt;
					&lt;img src="".$image_path.$name.$image_ext."" /&gt;
				&lt;/a&gt;";
	}

/* Execute the function. */

	create_html_link("home", "class="normal_link"");
	create_html_link("about", "class="normal_link"");
	create_html_link("contact", "class="normal_link"");
</pre>
<h4>Calculate the Number of Days Since Some other Date</h4>
<pre>/*
 *  Author: James Thompson, jtGraphic.net
 *
 *  Description
 *  ------------------------------------
 *  Simple.  This calculates the number of days since X date.
 *
 *  Arguments
 *  ------------------------------------
 *  $date - the date in this format: 'YYYY-MM-DD HH:MM:SS'
 *
 */

/* Build the function. */

	function num_days_since($date) {
		/* Do some time math. */
			$date = strtotime($date);
			$now = time();
			$difference = $now - $date;
			$days = $difference / 86400;

		/* Output the Value. */
			return $days;
	}

/* Execute the function. */

	/* Should return 0 */
		echo num_days_since(date("Y-m-d H:i:s"));
	/* Someone's birthday at 6:02:55AM on Oct 23, 1974 */
		echo num_days_since("1974-10-23 06:02:55");
	/* Since Jan 1, 2009 - no need for time */
		echo num_days_since("2009-01-01");
</pre>
<h3>Examples Elsewhere on this Site:</h3>
<p><a href="http://www.jtgraphic.net/2009/10/tidbit-tuesday-php-holiday-notices-business-sites/" target="_blank">Holiday Notices</a></p>
<h3>Conclusion</h3>
<p>So that&#8217;s the basics.  Functions can be very powerful in reducing the code on your websites.  If you&#8217;d like to see some more <a href="http://www.jtgraphic.net/tag/custom-functions/" target="_blank">custom functions</a>, check out my <a href="http://www.jtgraphic.net/tag/Tidbit-Tuesday/" target="_blank">Tidbit Tuesdays on PHP</a> If you have questions, let me know in the comments.</p>
<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fjtgraphic.net%2Fphp-function-friday-function%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://jtgraphic.net/php-function-friday-function/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://jtgraphic.net/php-function-friday-function/"  data-text="PHP Function Friday: function" data-count="horizontal" data-via="jtgraphic">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://jtgraphic.net/php-function-friday-function/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://jtgraphic.net/php-function-friday-function/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Originally posted on jtGraphic.net: <a href="http://jtgraphic.net/php-function-friday-function/">PHP Function Friday: function</a></p>]]></content:encoded>
			<wfw:commentRss>http://jtgraphic.net/php-function-friday-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

