<?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>PHP Magic Book - Free PHP Scripts, Tutorials and Downloads &#187; date</title>
	<atom:link href="http://www.phpmagicbook.com/tag/date/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmagicbook.com</link>
	<description>PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips</description>
	<lastBuildDate>Tue, 15 Jun 2010 13:22:30 +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>Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</title>
		<link>http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/</link>
		<comments>http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 04:00:44 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Date & Time]]></category>
		<category><![CDATA[Select]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[Useful Scripts]]></category>
		<category><![CDATA[php mySQL]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[month]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=296</guid>
		<description><![CDATA[If you have to create a date object of future or past, you can do it by using the second parameter of PHP date function. This is extremely useful when doing BETWEEN comparison in MySQL. You can build the date and bind it to query. For Tomorrow &#60;?php echo date&#40;&#34;D F d Y&#34;,strtotime&#40;&#34;+1 days&#34;&#41;&#41;; // [...]<p><a href="http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/">Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you have to create a date object of future or past, you can do it by using the second parameter of PHP date function. This is extremely useful when doing BETWEEN comparison in MySQL. You can build the date and bind it to query.</p>
<p><span id="more-296"></span></p>
<p><strong>For Tomorrow</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D F d Y&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;+1 days&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">// Same applies for months e.g. &quot;+1 months&quot;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>For Yesterday</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D F d Y&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-1 days&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">// Same applies for months e.g. &quot;-1 months&quot;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you want to select all records which are not older than 7 days the syntex will be;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from table where postedDate &gt; '&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-7 days&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you want to select subscriptions of the user which have been made in last two months you can do it by;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from table where postedDate &gt; '&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-2 months&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If you want to select some records which are one month old you can do it;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from table where postedDate &gt; '&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-1 months&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/">Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/" title="Date Difference In PHP &#8211; Find Date Difference">Date Difference In PHP &#8211; Find Date Difference</a></li><li><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/" title="PHP Date and Time With Season or Weather Information">PHP Date and Time With Season or Weather Information</a></li><li><a href="http://www.phpmagicbook.com/date-and-time-in-php/" title="Date And Time Scripts In PHP">Date And Time Scripts In PHP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Date Difference In PHP &#8211; Find Date Difference</title>
		<link>http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/</link>
		<comments>http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 20:05:15 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Checks]]></category>
		<category><![CDATA[Date & Time]]></category>
		<category><![CDATA[Useful Scripts]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date difference in php]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=217</guid>
		<description><![CDATA[We can find out the difference between two given dates in PHP very easily. Consider the following PHP script: &#60;?php function dateDiff&#40;$dformat, $endDate, $beginDate&#41; &#123; $date_parts1=explode&#40;$dformat, $beginDate&#41;; $date_parts2=explode&#40;$dformat, $endDate&#41;; $start_date=gregoriantojd&#40;$date_parts1&#91;1&#93;, $date_parts1&#91;0&#93;, $date_parts1&#91;2&#93;&#41;; $end_date=gregoriantojd&#40;$date_parts2&#91;1&#93;, $date_parts2&#91;0&#93;, $date_parts2&#91;2&#93;&#41;; return $end_date - $start_date; &#125; // adjust date parts according to date format 102 for d-m-y and 012 for m-d-y [...]<p><a href="http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/">Date Difference In PHP &#8211; Find Date Difference</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>We can find out the difference between two given dates in PHP very easily. Consider the following PHP script:</p>
<p><span id="more-266"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> dateDiff<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dformat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$endDate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$beginDate</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
           <span style="color: #000088;">$date_parts1</span><span style="color: #339933;">=</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dformat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$beginDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #000088;">$date_parts2</span><span style="color: #339933;">=</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dformat</span><span style="color: #339933;">,</span> <span style="color: #000088;">$endDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #000088;">$start_date</span><span style="color: #339933;">=</span><span style="color: #990000;">gregoriantojd</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$date_parts1</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date_parts1</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date_parts1</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #000088;">$end_date</span><span style="color: #339933;">=</span><span style="color: #990000;">gregoriantojd</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$date_parts2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date_parts2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date_parts2</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #b1b100;">return</span> <span style="color: #000088;">$end_date</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$start_date</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// adjust date parts according to date format 102 for d-m-y and 012 for m-d-y</span>
<span style="color: #000088;">$date1</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;30-06-2008&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$date2</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;06-08-2008&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;If we minus &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$date1</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; from &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$date2</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; we get &quot;</span> <span style="color: #339933;">.</span> dateDiff<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Result will be</strong><br />
If we minus 30-06-2008 from 06-08-2008 we get 37</p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/08/date-difference.rar' class="download">Download Script</a></p>
<p><a href="http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/">Date Difference In PHP &#8211; Find Date Difference</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/" title="Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP">Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</a></li><li><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/" title="PHP Date and Time With Season or Weather Information">PHP Date and Time With Season or Weather Information</a></li><li><a href="http://www.phpmagicbook.com/date-and-time-in-php/" title="Date And Time Scripts In PHP">Date And Time Scripts In PHP</a></li><li><a href="http://www.phpmagicbook.com/find-screen-resolution-with-php/" title="Find Screen Resolution With PHP">Find Screen Resolution With PHP</a></li><li><a href="http://www.phpmagicbook.com/find-file-path-at-server-using-php/" title="Find File Path At Server Using PHP">Find File Path At Server Using PHP</a></li><li><a href="http://www.phpmagicbook.com/find-page-url-php/" title="Find Page URL With PHP &#8211; File Path">Find Page URL With PHP &#8211; File Path</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Date and Time With Season or Weather Information</title>
		<link>http://www.phpmagicbook.com/php-date-and-time-with-season/</link>
		<comments>http://www.phpmagicbook.com/php-date-and-time-with-season/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 19:13:45 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Date & Time]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=209</guid>
		<description><![CDATA[This script will tell you current date and time with current season or weather. &#60;?php echo date&#40;&#34;l, d F Y - H:i:s a &#34;&#41;; echo &#34;(GMT+05:00) - &#34;; function season&#40;&#41; &#123; $limits=array&#40;'/12/21'=&#62;'Winter','/09/21'=&#62;'Autumn', '/06/21'=&#62;'Summer','/03/21'=&#62;'Spring','/12/31'=&#62;'Winter'&#41;; foreach &#40;$limits AS $key =&#62; $value&#41; &#123; $limit=date&#40;&#34;Y&#34;&#41;.$key; if &#40;strtotime&#40;&#34;now&#34;&#41;&#62;strtotime&#40;$limit&#41;&#41; &#123; return $value; &#125; &#125; &#125; echo season&#40;&#41;; ?&#62; Sample Display Thursday, [...]<p><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/">PHP Date and Time With Season or Weather Information</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This script will tell you current date and time with current season or weather.</p>
<p><span id="more-263"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;l, d F Y - H:i:s a &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;(GMT+05:00) - &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> season<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$limits</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/12/21'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Winter'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/09/21'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Autumn'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'/06/21'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Summer'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/03/21'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Spring'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/12/31'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'Winter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limits</span> <span style="color: #b1b100;">AS</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;now&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span>strtotime<span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #b1b100;">return</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> season<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Sample Display</strong><br />
Thursday, 07 August 2008 &#8211; 01:04:27 am (GMT+05:00) &#8211; Summer</p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/08/date-with-season.rar' class="download">Download Script</a></p>
<p><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/">PHP Date and Time With Season or Weather Information</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/" title="Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP">Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</a></li><li><a href="http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/" title="Date Difference In PHP &#8211; Find Date Difference">Date Difference In PHP &#8211; Find Date Difference</a></li><li><a href="http://www.phpmagicbook.com/date-and-time-in-php/" title="Date And Time Scripts In PHP">Date And Time Scripts In PHP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/php-date-and-time-with-season/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date And Time Scripts In PHP</title>
		<link>http://www.phpmagicbook.com/date-and-time-in-php/</link>
		<comments>http://www.phpmagicbook.com/date-and-time-in-php/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 06:30:13 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Date & Time]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=15</guid>
		<description><![CDATA[Date and time in PHP is very useful and handy because it provides you the result of time and date, in the way you want. Using Date and Time functions in flash we can display date and time at website in a number of ways and formats. Below are some examples and best practices. Below [...]<p><a href="http://www.phpmagicbook.com/date-and-time-in-php/">Date And Time Scripts In PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Date and time in PHP is very useful and handy because it provides you the result of time and date, in the way you want. Using Date and Time functions in flash we can display date and time at website in a number of ways and formats. Below are some examples and best practices. </p>
<p><span id="more-149"></span></p>
<p>Below the script shows you how to create and use the date and time functions.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D M d, Y H:i:s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>OR</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The time is &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Hours, minutes, seconds</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; and the date is &quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'j F Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Day name, month name, year</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This will output: <strong>Fri Jan 03, 2003 12:01:21</strong> (or the current date/time)<br />
To change the formatting of the date and time you only need to change the syntax in the quotes to suit your new purpose.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d.m.Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>It will provide you with this result. i.e. (Tue, 13.06.2006)</p>
<p>Simply put this code into your web page and save webpage in php extension and you will get date and time displayed at your website.</p>
<h4>Formatting</h></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Assuming today is: March 10th, 2001, 5:16:18 pm</span>
&nbsp;
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y, g:i a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// March 10, 2001, 5:16 pm</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m.d.y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 03.10.01</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;j, n, Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 10, 3, 2001</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ymd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 20010310</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'h-i-s, j-m-y, it is w Day z '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 05-16-17, 10-03-01, 1631 1618 6 Fripm01</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\i\t \i\s \t\h\e jS \d\a\y.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// It is the 10th day.</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D M j G:i:s T Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Sat Mar 10 15:16:08 MST 2001</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'H:m:s \m \i\s\ \m\o\n\t\h'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 17:03:17 m is month</span>
<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H:i:s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 17:16:17</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h4>More Resources</h4>
<p><a rel="nofollow" target="_blank" href="http://www.php.net/manual/en/function.date.php" target="_blank">http://www.php.net/manual/en/function.date.php</a></p>
<p><a href="http://www.phpmagicbook.com/date-and-time-in-php/">Date And Time Scripts In PHP</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/date-object-for-future-or-past-easy-monthwise-or-datewise-records-selection/" title="Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP">Date Object For Future or Past &#8211; Easy Monthwise or Datewise Records Selection Using PHP</a></li><li><a href="http://www.phpmagicbook.com/date-difference-in-php-find-date-difference/" title="Date Difference In PHP &#8211; Find Date Difference">Date Difference In PHP &#8211; Find Date Difference</a></li><li><a href="http://www.phpmagicbook.com/php-date-and-time-with-season/" title="PHP Date and Time With Season or Weather Information">PHP Date and Time With Season or Weather Information</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/date-and-time-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
