<?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>荷包蛋博客 &#187; useful</title>
	<atom:link href="http://www.hebaodans.com/tag/useful/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hebaodans.com</link>
	<description>好的心态是成功的开始</description>
	<lastBuildDate>Tue, 20 Jul 2010 17:32:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>IIS 7.0 Appcmd 使用</title>
		<link>http://www.hebaodans.com/2008/10/iis7-appcmd-useful/</link>
		<comments>http://www.hebaodans.com/2008/10/iis7-appcmd-useful/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 03:51:38 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[win2008]]></category>
		<category><![CDATA[appcmd]]></category>
		<category><![CDATA[iis7]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.hebaodans.com/?p=117</guid>
		<description><![CDATA[ IIS 7.0：Appcmd.exe IIS 7.0 提供了一个新的命令行工具 Appcmd.exe，可以使用该工具来配置和查询 Web 服务器上的对象，并以文本或 XML 格式返回输出。下面是一些可以使用 Appcmd.exe 完成的任务的示例： ? 创建和配置站点、应用程序、应用程序池和虚拟目录。   ? 停止和启动站点。   ? 启动、停止和回收应用程序池。   ? 查看有关在 Web 服务器上运行的工作进程和请求的信息。   Appcmd.exe 为常见的查询和配置任务提供了一致的命令，从而降低了学习语法的复杂性。例如，您可以使用 list 命令来搜索有关对象（如应用程序）的信息，也可以使用 add 命令来创建对象（如站点）。 另外，您还可以将命令组合在一起使用，以返回与 Web 服务器上对象相关的更为复杂的数据，或执行更为复杂的任务。例如，您可以完成类似如下任务的复杂任务：停止所有具有运行时间超过六十秒的请求的站点。 IIS 7.0：启动 Appcmd.exe 如果要通过使用命令 shell 窗口来配置 IIS 7.0 设置，请打开 Appcmd.exe。Appcmd.exe 位于 %windir%\system32\inetsrv 目录中，只有管理员帐户或身为相应计算机上 Administrators 组成员的用户才可以访问此目录。此外，Administrators 组的成员必须在 Windows Vista® 和 Windows Server® 2008 中以提升的权限启动 Appcmd.exe，才能查看和更改以下服务器级配置文件中的设置：Machine.config、根 [...]]]></description>
			<content:encoded><![CDATA[<p> IIS 7.0：Appcmd.exe<br />
IIS 7.0 提供了一个新的命令行工具 Appcmd.exe，可以使用该工具来配置和查询 Web 服务器上的对象，并以文本或 XML 格式返回输出。下面是一些可以使用 Appcmd.exe 完成的任务的示例：</p>
<p>? 创建和配置站点、应用程序、应用程序池和虚拟目录。<br />
 <br />
? 停止和启动站点。<br />
 <br />
? 启动、停止和回收应用程序池。<br />
 <br />
? 查看有关在 Web 服务器上运行的工作进程和请求的信息。<br />
 </p>
<p>Appcmd.exe 为常见的查询和配置任务提供了一致的命令，从而降低了学习语法的复杂性。例如，您可以使用 list 命令来搜索有关对象（如应用程序）的信息，也可以使用 add 命令来创建对象（如站点）。</p>
<p>另外，您还可以将命令组合在一起使用，以返回与 Web 服务器上对象相关的更为复杂的数据，或执行更为复杂的任务。例如，您可以完成类似如下任务的复杂任务：停止所有具有运行时间超过六十秒的请求的站点。</p>
<h1 class="title">IIS 7.0：启动 Appcmd.exe</h1>
<div class="intro">
<p>如果要通过使用命令 shell 窗口来配置 IIS 7.0 设置，请打开 Appcmd.exe。Appcmd.exe 位于 %<em>windir</em>%\system32\inetsrv 目录中，只有管理员帐户或身为相应计算机上 Administrators 组成员的用户才可以访问此目录。此外，Administrators 组的成员必须在 Windows Vista® 和 Windows Server® 2008 中以提升的权限启动 Appcmd.exe，才能查看和更改以下服务器级配置文件中的设置：Machine.config、根 Web.config 文件（位于 .NET Framework 目录中）以及 ApplicationHost.config。查看或更改站点或应用程序目录中的 Web.config 文件的用户必须对这些目录中的文件具有读取和写入权限。</p>
<table class="sidebarContent" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;">
<td class="dropCapQ" style="vertical-align: top;" align="left"> </td>
<td style="vertical-align: top;">
<h5><img src="http://www.hebaodans.com/library/gallery/templates/MNP2.Common/images/note.gif" border="0" alt="" width="10" height="10" />注：</h5>
</td>
</tr>
<tr id="eCEME" style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;" valign="top">
<td class="dropCapQ" align="right"> </td>
<td>如果您运行的是 64 位 Windows，请从 <em>本地驱动器</em>\system32\inetsrv 目录而不是 <em>本地驱动器</em>\syswow64\inetsrv 目录使用 Appcmd.exe。</td>
</tr>
</tbody>
</table>
<table class="numberedList" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;">
<td class="dropCapQ" style="vertical-align: top;" align="left"> </td>
<td style="vertical-align: top;"><strong>启动 Appcmd.exe</strong></td>
</tr>
<tr id="eCEWE" style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;" valign="top">
<td class="dropCapQ" align="right"> </td>
<td>
<table border="0">
<tbody>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px; border: red 1px inset;">
<td style="vertical-align: top;" colspan="2">
<div class="intro">
<table class="sidebarContent" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;">
<td class="dropCapQ" style="vertical-align: top;" align="left"> </td>
<td style="vertical-align: top;">
<h5><img src="http://www.hebaodans.com/library/gallery/templates/MNP2.Common/images/note.gif" border="0" alt="" width="10" height="10" />注：</h5>
</td>
</tr>
<tr id="eCE4E" style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px;" valign="top">
<td class="dropCapQ" align="right"> </td>
<td>如果您登录到计算机时使用的是管理员帐户，您可以双击 <strong>Appcmd.exe</strong>。</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px; border: red 1px inset;">
<td class="pageNumber" style="vertical-align: top; line-height: 140%;">1.</td>
<td style="vertical-align: top;">单击<strong>“开始”</strong>，然后单击<strong>“运行”</strong>。</td>
</tr>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px; border: red 1px inset;">
<td class="pageNumber" style="vertical-align: top; line-height: 140%;">2.</td>
<td style="vertical-align: top;">在<strong>“运行”</strong>对话框中的<strong>“打开”</strong>框中，键入 <strong>%</strong><em>windir</em><strong>%\system32\inetsrv</strong>。</td>
</tr>
<tr style="padding-right: 0px; padding-left: 0px; padding-bottom: 7px; padding-top: 0px; border: red 1px inset;">
<td class="pageNumber" style="vertical-align: top; line-height: 140%;">3.</td>
<td style="vertical-align: top;">右键单击 <strong>Appcmd.exe</strong>，然后单击<strong>“以管理员身份运行”</strong>。<strong><span class='wp_keywordlink_affiliate'><a href="http://www.hebaodans.com/tag/appcmd/" title="View all posts in appcmd" target="_blank">appcmd</a></span> /?</strong>若要查看有关特定 Appcmd.exe 对象（例如可以与 <strong>site</strong> 对象一起使用的命令）的帮助信息，请在命令提示符处键入如下命令，然后按 Enter：<strong><span class='wp_keywordlink_affiliate'><a href="http://www.hebaodans.com/tag/appcmd/" title="View all posts in appcmd" target="_blank">appcmd</a></span> site /?</strong>若要查看有关可以使用 Appcmd.exe 对象和命令（如 <strong>site</strong> 对象和 <strong>add</strong> 命令）配置的设置的帮助信息，请在命令提示符处键入如下命令，然后按 Enter：</p>
<p><strong>appcmd add site /?</strong></td>
</tr>
</tbody>
</table>
<p>设置path环境 path=%path%;%SystemRoot%\System32\inetsrv</p>
<p>列出站点名称 appcmd list site /text:site.name</p>
<p>列出站点物理路径 APPCMD list vdirs /text:physicalPath</p>
<p> </p>
<p><span style="font-size: xx-small; color: #000099;">备份</span></p>
<p><span style="font-size: 14pt; color: #000099;"><strong>&gt;AppCmd Add Backup &#8220;BackupName&#8221;</strong></span></p>
<p><span style="font-size: 14pt; color: #000099;"><span style="font-size: xx-small;">罗列备份</span></span></p>
<p><span style="font-size: 14pt; color: #000099;"><span style="font-size: 14pt; color: #000099;"><strong>&gt;AppCmd List Backup</strong></span></span></p>
<p><span style="font-size: 14pt; color: #000099;"><span style="font-size: xx-small;">恢复</span></span></p>
<p><span style="font-size: 14pt; color: #000099;"><span style="font-size: xx-small;"><span style="font-size: 14pt; color: #000099;"><strong>&gt;AppCmd Restore Backup &#8220;BackupName&#8221;</strong></span></span></span></p>
<p><strong></strong></p>
<h2>1) Creating a backup</h2>
<p>To create a backup, simply type in:</p>
<p><strong><span style="font-size: 14pt; color: #000099;">&gt;AppCmd Add Backup &#8220;BackupName&#8221;</span></strong></p>
<p>You can omit the name, in which case AppCmd is going to generate the backup name automatically using the current date and time.  When a backup is created, the following happens:</p>
<ol>
<li>A directory with the backup name is created under the <em>%windir%\system32\inetsrv\backup</em> directory.</li>
<li>AppCmd copies the current configuration files into the backup directory, including <em>applicationHost.config<strong> </strong></em>(IIS global configuration), <em>administration.config</em> (Admin Tool&#8217;s configuration), <em>metabase.xml</em> and <em>mbschema.xml.</em>  The last two files contain the metabase data that is still used by some IIS services including SMTP and FTP, that have not been migrated to the new configuration system.  AppCmd only backs up the files that are there, so if you delete any of these files, and then make a backup, the backup will not contain the missing files. </li>
</ol>
<h2> </h2>
<h2>2) Managing existing backups</h2>
<p>To list the backups that exist on the server, type in:</p>
<p><strong><span style="font-size: 14pt; color: #000099;">&gt;AppCmd List Backup</span></strong></p>
<p>This will list the backup objects, including their names that can be used to restore or delete them.  To delete any of these backups if its no longer needed, type in:</p>
<p><strong><span style="font-size: 14pt; color: #000099;">&gt;AppCmd List Backup &#8220;BackupName&#8221;</span></strong></p>
<h2> </h2>
<h2> </h2>
<h2>3) Restoring a backup</h2>
<p>To restore a backup, type in:</p>
<p><strong><span style="font-size: 14pt; color: #000099;">&gt;AppCmd Restore Backup &#8220;BackupName&#8221;</span></strong></p>
<p>This will stop IIS (equivalent to calling IISRESET.EXE /STOP), and overwrite the server&#8217;s state with the files in the specified backup directory.  Then, IIS will be re-started (equivalent to calling IISRESET.EXE /START).</p>
<p>If you do no want AppCmd to stop IIS (which can take a while), and instead want to stop and start services yourself, you can include the <span style="font-size: 14pt; color: #000099;"><strong>/stop:false</strong></span> parameter.  Typically, only the IISADMIN service requires to be stopped so that the <em>mbschema.xml</em> file can be restored, if services like FTP or SMTP are being used.  Other files, including <em>applicationHost.config</em> and <em>administration.config,</em> are not locked by the configuration system so they can be restored without stopping IIS, and IIS components will pick up the changes.</p>
<p>I recommend that you make backups every time before making significant changes to the IIS7 configuration, which can save you a lot of time when something doesnt go as planned.  I&#8217;ve watched &#8220;AppCmd Restore Backup&#8221; come to the rescue more times then I can count, so its almost always the first thing that I do when I begin working with a new server, or help someone on the team investigate an issue.</p>
<p>In Windows Server &#8220;Longhorn&#8221; beta 3, we are adding a Configuration History service that automatically makes configuration backups every 2 minutes whenever configuration is changed.  This often eliminates the need to do manual backups, but not completely &#8211; often its desireable to make a backup at a specific point before making changes, so that that exact state is saved and can be restored at any point.  More info on the Configuration History service in a future post</p>
<p>转载来源</p>
<p><a href="http://technet2.microsoft.com/windowsserver2008/zh-CHS/library/ec52c53b-6aff-4d76-995e-3d222588bf322052.mspx?mfr=true">http://technet2.microsoft.com/windowsserver2008/zh-CHS/library/ec52c53b-6aff-4d76-995e-3d222588bf322052.mspx?mfr=true</a></p>
<p> </p>
<p>更详细用法</p>
<p> </p>
<p><strong>Application Pools<br />
</strong><span style="font-size: small; font-family: Calibri;">1. Recycle all application pools (replace recycle with start/stop to start/stop all apppools)<br />
</span></p>
<div><span style="font-size: small;"><span style="font-family: Calibri;"></p>
<div><em style="mso-bidi-font-style: normal;">appcmd list apppool /xml | appcmd recycle apppool /in</em></div>
<p></span></span></div>
<p><span style="font-size: small;"><span style="font-family: Calibri;"><em style="mso-bidi-font-style: normal;">2. Stop application pools with word &#8220;cheap&#8221; in it<br />
<em style="mso-bidi-font-style: normal;">appcmd list apppool /name:&#8221;$=*cheap*&#8221; /xml | appcmd stop apppool /in</em></p>
<div><span style="font-size: small; font-family: Calibri;"><br />
3. Set property enable32BitAppOnWin64 to true for all apppools (Filter apppools as in 2 if needed)<br />
<em style="mso-bidi-font-style: normal;">appcmd list apppool /xml | appcmd set apppool /in /enable32BitAppOnWin64:true</em></span></div>
<p></em></span></span><span style="font-size: small; font-family: Calibri;">4. Start apppools which are stopped<br />
<em style="mso-bidi-font-style: normal;">appcmd list apppool /state:Stopped /xml | appcmd start apppool /in</em></p>
<p>5. Recycle application pools which are used in some applications<br />
appcmd list app /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in<br />
<em style="mso-bidi-font-style: normal;">appcmd list app /xml | appcmd recycle apppool /in (This might recycle one apppool multiple times)</em></p>
<p>6. Recycle apppools serving website “Default Web Site”</p>
<div><span style="font-size: small;"><span style="font-family: Calibri;"><em style="mso-bidi-font-style: normal;">appcmd list site &#8220;Default Web Site&#8221; /xml | appcmd list app /in /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in<br />
appcmd list app /site.name:&#8221;Default Web Site&#8221; /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in</em></span></span></div>
<p></span><span style="font-size: small;"><span style="font-family: Calibri;"><strong style="mso-bidi-font-weight: normal;">Sites</strong><br />
7. Start all the sites (Replace start with stop to stop all sites)<br />
<em style="mso-bidi-font-style: normal;">appcmd list site /xml | appcmd start site /in</em></p>
<p>8. Start the sites which are stopped<br />
<em style="mso-bidi-font-style: normal;">appcmd list site /state:stopped /xml | appcmd start site /in</em></p>
<p>9. Set serverAutoStart to false for all sites<br />
<em style="mso-bidi-font-style: normal;">appcmd list site /xml | appcmd set site /serverAutoStart:false /in</em></p>
<p>10. Keep sites config data and restore later</p>
<div><span style="font-size: small;"><span style="font-family: Calibri;"><em style="mso-bidi-font-style: normal;">appcmd list site /config /xml &gt; sites.xml<br />
appcmd add sites /in &lt; sites.xml</em></span></span></div>
<p></span></span><span style="font-size: small;"><span style="font-family: Calibri;"><strong style="mso-bidi-font-weight: normal;">Applications and Vdirs</strong><br />
11. Delete all apps which are using a particular apppool<br />
<em style="mso-bidi-font-style: normal;">appcmd list apppool DefaultAppPool /xml | appcmd list app /in /xml | appcmd delete app /in</em></p>
<p>12. Move all applications in a site to NewAppPool apppool<br />
<em style="mso-bidi-font-style: normal;">appcmd list app /site.name:&#8221;Default Web Site&#8221; /xml | appcmd set app /in /applicationPool:NewAppPool</em></p>
<p>13. List all sites with &#8220;/test&#8221; app<br />
<em style="mso-bidi-font-style: normal;">appcmd list app /path:&#8221;/test&#8221; /xml | appcmd list site /in</em></p>
<p>14. List apps created by user10 (assuming all his apps under a folder whose name contains user10)<br />
<em style="mso-bidi-font-style: normal;">appcmd list vdir /physicalPath:&#8221;$=*user10*&#8221; /xml | appcmd list app /in</em></p>
<p>15. List sites which read from C:\inetput\wwwroot<br />
<em style="mso-bidi-font-style: normal;">appcmd list vdir /physicalPath:C:\inetput\wwwroot /xml | appcmd list app /xml /in | appcmd list site /in</em></p>
<p>16. List the vdirs of sites which are stopped<br />
<em style="mso-bidi-font-style: normal;">appcmd list site /state:stopped /xml | appcmd list app /xml /in | appcmd list vdir /in</em></p>
<p><strong style="mso-bidi-font-weight: normal;">Worker processes and Requests</strong><br />
17. Stop apppools of requests running for more than 60 seconds<br />
<em style="mso-bidi-font-style: normal;">appcmd list request /xml /time:&#8221;$&gt;60000&#8243; | appcmd list apppool /in /xml | appcmd stop apppool /in</em></p>
<p>18. List apps served by wp 3600<br />
<em style="mso-bidi-font-style: normal;">appcmd list wp 3600 /xml | appcmd list apppool /xml /in | appcmd list app /in</em></p>
<p><strong style="mso-bidi-font-weight: normal;">Modules</strong><br />
19. Disable all managed modules<br />
<em style="mso-bidi-font-style: normal;">appcmd list module /preCondition:managedHandler /xml | appcmd delete module /in</em></p>
<p>20. Uninstall all native modules<br />
<em style="mso-bidi-font-style: normal;">appcmd list module /type:&#8221;" /xml | appcmd uninstall module /in</em></p>
<p>21. Unlock all module entries under system.webServer/modules (won’t work on vista)<br />
<em style="mso-bidi-font-style: normal;">appcmd list module /xml | appcmd set config /lockItem:false /in</em></p>
<div><strong style="mso-bidi-font-weight: normal;"><span style="font-size: small;"><span style="font-family: Calibri;"></p>
<div></div>
<p></span></span></strong></div>
<p></span></span><strong style="mso-bidi-font-weight: normal;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="mso-spacerun: yes;"><span style="font-size: small;"><span style="font-family: Calibri;"><strong style="mso-bidi-font-weight: normal;">Configuration</strong><br />
22. Keep config of a particular section and restore later<br />
</span></span><em style="mso-bidi-font-style: normal;"><span style="font-size: small; font-family: Calibri;">appcmd list config </span><a href="http://localhost/app1/"><span style="font-size: small; color: #0000ff; font-family: Calibri;">http://localhost/app1/</span></a><span style="font-size: small; font-family: Calibri;"> /section:caching /xml /config &gt; config.xml<br />
appcmd set config </span><a href="http://localhost/app1"><span style="font-size: small; color: #0000ff; font-family: Calibri;">http://localhost/app1</span></a><span style="font-size: small; font-family: Calibri;"> /in &lt; config.xml</span></em><strong style="mso-bidi-font-weight: normal;"></strong></p>
<div></div>
<p></span></span></span></strong><span style="font-size: small; font-family: Calibri;"><span style="font-size: small;"><span style="font-family: Calibri;"><strong style="mso-bidi-font-weight: normal;">Backups and Traces<br />
</strong>23. Delete all backups<br />
<em style="mso-bidi-font-style: normal;">appcmd list backup /xml | appcmd delete backup /in</em></span></span></p>
<div><strong style="mso-bidi-font-weight: normal;"></strong></div>
<p></span><strong style="mso-bidi-font-weight: normal;"><span style="font-size: small;"><span style="font-family: Calibri;">24. List sites generating 404<br />
<em style="mso-bidi-font-style: normal;">appcmd list trace /statusCode:404 /xml | appcmd list site /in</em><strong style="mso-bidi-font-weight: normal;"></strong></span></span><em style="mso-bidi-font-style: normal;"><span style="font-size: small; font-family: Calibri;"><br />
</span></em></p>
<p></strong><em style="mso-bidi-font-style: normal;"><span style="font-size: small; font-family: Calibri;">转载来源 <a href="http://blogs.iis.net/ksingla/archive/2007/06/17/things-you-can-do-by-piping-appcmd-commands.aspx">http://blogs.iis.net/ksingla/archive/2007/06/17/things-you-can-do-by-piping-appcmd-commands.aspx</a></span></em></td>
</tr>
</tbody>
</table>
</div>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.hebaodans.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.hebaodans.com/2008/10/iis7-appcmd-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP的日期时间函数date()</title>
		<link>http://www.hebaodans.com/2008/08/php-date-function/</link>
		<comments>http://www.hebaodans.com/2008/08/php-date-function/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 06:35:08 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.hebaodans.com/?p=86</guid>
		<description><![CDATA[1，年-月-日 echo date(&#8216;Y-m-j&#8217;); 2007-02-6 echo date(&#8216;y-n-j&#8217;); 07-2-6 大写Y表示年四位数字，而小写y表示年的两位数字； 小写m表示月份的数字(带前导)，而小写n则表示不带前导的月份数字。 echo date(&#8216;Y-M-j&#8217;); 2007-Feb-6 echo date(&#8216;Y-m-d&#8217;); 2007-02-06 大写M表示月份的3个缩写字符，而小写m则表示月份的数字(带前导0); 没有大写的J，只有小写j表示月份的日期，无前导o；若需要月份带前导则使用小写d。 echo date(&#8216;Y-M-j&#8217;); 2007-Feb-6 echo date(&#8216;Y-F-jS&#8217;); 2007-February-6th 大写M表示月份的3个缩写字符，而大写F表示月份的英文全写。(没有小写f) 大写S表示日期的后缀，比如“st”、“nd”、“rd”和“th”，具体看日期数字为何。 小结： 表示年可以用大写的Y和小写y; 表示月可以用大写F、大写M、小写m和小写n(分别表示字符和数字的两种方式); 表示日可以用小写d和小写j，大写S表示日期的后缀。 2，时:分:秒 默认情况下，PHP解释显示的时间为“格林威治标准时间”，与我们本地的时间相差8个小时。 echo date(&#8216;g:i:s a&#8217;); 5:56:57 am echo date(&#8216;h:i:s A&#8217;); 05:56:57 AM 小写g表示12小时制，无前导0，而小写h则表示有前导0的12小时制。 当使用12小时制时需要表明上下午，小写a表示小写的“am”和“pm”，大写A表示大写的“AM”和“PM”。 echo date(&#8216;G:i:s&#8217;); 14:02:26 大写G表示24小时制的小时数，但是不带前导的；使用大写的H表示带前导的24小时制小时数 小结： 字母g表示小时不带前导，字母h表示小时带前导； 小写g、h表示12小时制，大写G、H表示24小时制。 3，闰年、星期、天 echo date(&#8216;L&#8217;); 今年是否闰年：0 echo [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1，年-月-日<br />
</strong>echo <span class='wp_keywordlink_affiliate'><a href="http://www.hebaodans.com/tag/date/" title="View all posts in date" target="_blank">date</a></span>(&#8216;Y-m-j&#8217;);<br />
2007-02-6</p>
<p>echo <span class='wp_keywordlink_affiliate'><a href="http://www.hebaodans.com/tag/date/" title="View all posts in date" target="_blank">date</a></span>(&#8216;y-n-j&#8217;);<br />
07-2-6</p>
<p>大写Y表示年四位数字，而小写y表示年的两位数字；<br />
小写m表示月份的数字(带前导)，而小写n则表示不带前导的月份数字。</p>
<p>echo date(&#8216;Y-M-j&#8217;);<br />
2007-Feb-6</p>
<p>echo date(&#8216;Y-m-d&#8217;);<br />
2007-02-06</p>
<p>大写M表示月份的3个缩写字符，而小写m则表示月份的数字(带前导0);<br />
没有大写的J，只有小写j表示月份的日期，无前导o；若需要月份带前导则使用小写d。</p>
<p>echo date(&#8216;Y-M-j&#8217;);<br />
2007-Feb-6</p>
<p>echo date(&#8216;Y-F-jS&#8217;);<br />
2007-February-6th</p>
<p>大写M表示月份的3个缩写字符，而大写F表示月份的英文全写。(没有小写f)<br />
大写S表示日期的后缀，比如“st”、“nd”、“rd”和“th”，具体看日期数字为何。</p>
<p><strong>小结：</strong><br />
表示年可以用大写的Y和小写y;<br />
表示月可以用大写F、大写M、小写m和小写n(分别表示字符和数字的两种方式);<br />
表示日可以用小写d和小写j，大写S表示日期的后缀。</p>
<p><strong>2，时:分:秒</strong></p>
<p>默认情况下，PHP解释显示的时间为“格林威治标准时间”，与我们本地的时间相差8个小时。</p>
<p>echo date(&#8216;g:i:s a&#8217;);<br />
5:56:57 am</p>
<p>echo date(&#8216;h:i:s A&#8217;);<br />
05:56:57 AM</p>
<p>小写g表示12小时制，无前导0，而小写h则表示有前导0的12小时制。<br />
当使用12小时制时需要表明上下午，小写a表示小写的“am”和“pm”，大写A表示大写的“AM”和“PM”。</p>
<p>echo date(&#8216;G:i:s&#8217;);<br />
14:02:26</p>
<p>大写G表示24小时制的小时数，但是不带前导的；使用大写的H表示带前导的24小时制小时数</p>
<p><strong>小结：</strong><br />
字母g表示小时不带前导，字母h表示小时带前导；<br />
小写g、h表示12小时制，大写G、H表示24小时制。</p>
<p><strong>3，闰年、星期、天</strong></p>
<p>echo date(&#8216;L&#8217;);<br />
今年是否闰年：0</p>
<p>echo date(&#8216;l&#8217;);<br />
今天是：Tuesday</p>
<p>echo date(&#8216;D&#8217;);<br />
今天是：Tue</p>
<p>大写L表示判断今年是否闰年，布尔值，为真返回1，否则为0；<br />
小写l表示当天是星期几的英文全写(Tuesday)；<br />
而使用大写D表示星期几的3个字符缩写(Tue)。</p>
<p>echo date(&#8216;w&#8217;);<br />
今天星期：2</p>
<p>echo date(&#8216;W&#8217;);<br />
本周是全年中的第 06 周</p>
<p>小写w表示星期几，数字形式表示<br />
大写W表示一年中的星期数</p>
<p>echo date(&#8216;t&#8217;);<br />
本月是 28 天</p>
<p>echo date(&#8216;z&#8217;);<br />
今天是今年的第 36 天</p>
<p>小写t表示当前月份又多少天<br />
小写z表示今天是本年中第几天</p>
<p><strong>4，其他</strong></p>
<p>echo date(&#8216;T&#8217;);<br />
UTC<br />
大写T表示服务器的时间区域设置</p>
<p>echo date(&#8216;I&#8217;);<br />
0<br />
大写I表示判断当前是否为夏令时，为真返回1，否则为0</p>
<p>echo date(&#8216;U&#8217;);<br />
1170769424<br />
大写U表示从1970年1月1日到现在的总秒数，就是Unix时间纪元的UNIX时间戳。</p>
<p>echo date(&#8216;c&#8217;);<br />
2007-02-06T14:24:43+00:00<br />
小写c表示ISO8601日期，日期格式为YYYY-MM-DD，用字母T来间隔日期和时间，时间格式为HH:MM:SS，时区使用格林威治标准时间(GMT)的偏差来表示。</p>
<p>echo date(&#8216;r&#8217;);<br />
Tue, 06 Feb 2007 14:25:52 +0000<br />
小写r表示RFC822日期。<br />
转载来源：<a href="http://www.cnbruce.com/blog/showlog.asp?log_id=1150&amp;cat_id=30">http://www.cnbruce.com/blog/showlog.asp?log_id=1150&amp;cat_id=30</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.hebaodans.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.hebaodans.com/2008/08/php-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
