{"id":128,"date":"2011-06-29T02:41:28","date_gmt":"2011-06-28T18:41:28","guid":{"rendered":"http:\/\/iwisdomsys.com\/?p=128"},"modified":"2015-08-12T10:10:28","modified_gmt":"2015-08-12T02:10:28","slug":"%e4%b8%80%e5%80%8bfunction%e6%90%9e%e5%ae%9a-asp-%e6%97%a5%e6%9c%9f%e6%99%82%e9%96%93%e6%a0%bc%e5%bc%8f%e8%bd%89%e6%8f%9b","status":"publish","type":"post","link":"http:\/\/iwisdomsys.com\/?p=128","title":{"rendered":"\u4e00\u500bFunction\u641e\u5b9a ASP \u65e5\u671f\u6642\u9593\u683c\u5f0f\u8f49\u63db"},"content":{"rendered":"<p>\u5728\u7db2\u8def\u4e0a\u641c\u5c0b\u5230\u4e00\u4f4d\u5927\u5927\u628a\u7169\u4eba\u7684\u65e5\u671f\u6642\u9593\u683c\u5f0f\u8f49\u63db\u5beb\u6210Function- <strong>DanDate<\/strong>\uff0c\u53ea\u8981\u7528\u9019\u500b\u51fd\u5f0f\uff0c\u5c31\u6c92\u6709\u8f49\u63db\u4e0d\u4e86\u7684\u65e5\u671f\u6642\u9593\u683c\u5f0f\u4e86<\/p>\n<p>\u4f8b\u5982\u8981\u628a\u73fe\u5728\u7684\u6642\u9593\u8f49\u6210 yyyy\/mm\/dd HH:MM:SS\uff0c\u53ea\u8981\u5f15\u7528\u4e0b\u5217<span style=\"font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;\">\u5c31\u53ef\u4ee5\u56c9<!--more--><\/span><\/p>\n<p>[codesyntax lang=&#8221;asp&#8221;]<br \/>\nDanDate(Now(), &#8220;%Y\/%m\/%d %H:%M:%S&#8221;)<br \/>\n[\/codesyntax]<\/p>\n<h2><strong>DanDate Function \u539f\u59cb\u78bc<\/strong><\/h2>\n<p>[codesyntax lang=&#8221;asp&#8221;]<\/p>\n<pre>&lt;%\r\nFunction DanDate(strDate, strFormat)\r\n\r\n'%m Month as a decimal no. 02\r\n'%b Abbreviated month name Feb\r\n'%B Full month name February\r\n'%d Day of the month 23\r\n'%j Day of the year 54\r\n'%y Year without century 98\r\n'%Y Year with century 1998\r\n'%w Weekday as integer 5 (0 is Sunday)\r\n'%a Abbreviated day name Fri\r\n'%A Weekday Name Friday\r\n'%I Hour in 12 hour format 12\r\n'%H Hour in 24 hour format 24\r\n'%M Minute as an integer 01\r\n'%S Second as an integer 55\r\n'%P AM\/PM Indicator PM\r\n'%% Actual Percent sign %%\r\n\r\n\tDim intPosItem\r\n\tDim intHourPart\r\n\tDim strHourPart\r\n\tDim strMinutePart\r\n\tDim strSecondPart\r\n\tDim strAMPM\r\n\r\n\tIf not IsDate(strDate) Then\r\n\t\tDanDate = strDate\r\n\t\tExit Function\r\n\tEnd If\r\n\r\n\tintPosItem = Instr(strFormat, \"%m\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        DatePart(\"m\",strDate) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%m\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%b\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        MonthName(DatePart(\"m\",strDate),True) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%b\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%B\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        MonthName(DatePart(\"m\",strDate),False) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%B\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%d\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        DatePart(\"d\",strDate) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%d\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%j\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        DatePart(\"y\",strDate) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%j\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%y\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        Right(DatePart(\"yyyy\",strDate),2) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%y\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%Y\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        DatePart(\"yyyy\",strDate) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%Y\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%w\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        DatePart(\"w\",strDate,1) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%w\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%a\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        WeekDayName(DatePart(\"w\",strDate,1),True) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%a\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%A\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        WeekDayName(DatePart(\"w\",strDate,1),False) &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%A\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%I\")\r\n\tDo While intPosItem &gt; 0\r\n\t\tintHourPart = DatePart(\"h\",strDate) mod 12\r\n\t\tif intHourPart = 0 then intHourPart = 12\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        intHourPart &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%I\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%H\")\r\n\tDo While intPosItem &gt; 0\r\n\t\tstrHourPart = DatePart(\"h\",strDate)\r\n\t\tif strHourPart &lt; 10 Then strHourPart = \"0\" &amp; strHourPart\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        strHourPart &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%H\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%M\")\r\n\tDo While intPosItem &gt; 0\r\n\t\tstrMinutePart = DatePart(\"n\",strDate)\r\n\t\tif strMinutePart &lt; 10 then strMinutePart = \"0\" &amp; strMinutePart\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        strMinutePart &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%M\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%S\")\r\n\tDo While intPosItem &gt; 0\r\n\t\tstrSecondPart = DatePart(\"s\",strDate)\r\n\t\tif strSecondPart &lt; 10 then strSecondPart = \"0\" &amp; strSecondPart\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        strSecondPart &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%S\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%P\")\r\n\tDo While intPosItem &gt; 0\r\n\t\tif DatePart(\"h\",strDate) &gt;= 12 then\r\n\t\t\tstrAMPM = \"PM\"\r\n\t\tElse\r\n\t\t\tstrAMPM = \"AM\"\r\n\t\tEnd If\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; _\r\n                        strAMPM &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%P\")\r\n\tLoop\r\n\r\n\tintPosItem = Instr(strFormat, \"%%\")\r\n\tDo While intPosItem &gt; 0\r\n                strFormat = Left(strFormat, intPosItem-1) &amp; \"%\" &amp; _\r\n                        Right(strFormat, Len(strFormat) - (intPosItem + 1))\r\n\t\tintPosItem = Instr(strFormat, \"%%\")\r\n\tLoop\r\n\r\n\tDanDate = strFormat\r\n\r\nEnd Function\r\n%&gt;<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7db2\u8def\u4e0a\u641c\u5c0b\u5230\u4e00\u4f4d\u5927\u5927\u628a\u7169\u4eba\u7684\u65e5\u671f\u6642\u9593\u683c\u5f0f\u8f49\u63db\u5beb\u6210Function- DanDate\uff0c\u53ea\u8981\u7528\u9019\u500b\u51fd\u5f0f\uff0c\u5c31\u6c92\u6709\u8f49 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/iwisdomsys.com\/?p=128\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u4e00\u500bFunction\u641e\u5b9a ASP \u65e5\u671f\u6642\u9593\u683c\u5f0f\u8f49\u63db\u3009<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[21,22,38,39],"_links":{"self":[{"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/posts\/128"}],"collection":[{"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=128"}],"version-history":[{"count":6,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":403,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions\/403"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=\/wp\/v2\/media\/133"}],"wp:attachment":[{"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iwisdomsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}