ASP格式日期 [英] ASP formatting date
本文介绍了ASP格式日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我试图让ASP的日期以特定的格式(年月日)现身。这是我到目前为止,但没有运气尝试。任何帮助是AP preciated。谢谢
< TR>
< TD>< B>调用日期和LT; / B>< / TD>
&所述;%对于i = -6至0%GT;
< TD ALIGN =中心>
&所述; A HREF =20a.asp cldate =&下;%回复于(DateTime.Date()+ i.ToString(年月日))%>中目标=_空白> X< / A>
< / TD>
<%下一步%GT;
< / TR>
解决方案
不好意思挖这件事,但它可能是帮助一些人。而不是如果小于10则添加前导零的逻辑,我经常用正确的命令,并随时添加一个前导零...
的Response.Write< A HREF =20a.asp cldate =&放?;年(数值指明MyDate)及右(0&放大器;月份(数值指明MyDate),2)及右(0和天(数值指明MyDate),2)及TARGET =_空白> X< / A>中
..这样,你不需要一个单独的函数,它可以在同一行中完成。我不能为它的效率说话,但它似乎合乎逻辑的。
Hello there I'm trying to get a date in ASP to show up in a particular format (yyyymmdd). This is what I've tried so far but no luck. Any help is appreciated. Thanks
<tr>
<td><b>Call Date</b></td>
<% for i = -6 to 0 %>
<td align=center>
<a href="20a.asp?cldate=<% response.write(DateTime.Date()+i.ToString("yyyyMMdd")) %>" target="_blank">X</a>
</td>
<% Next %>
</tr>
解决方案
Sorry to dig this up, but it might be of help to some people. Rather than the "If<10 then add leading zero" logic, I often use the right command and always add a leading zero...
response.write "<a href=""20a.asp?cldate=" & Year(myDate) & Right("0" & Month(myDate), 2) & right("0" & Day(myDate), 2) & """ target=""_blank"">X</a>"
..This way, you don't need a separate function, and it can be done on one line. I can't speak for the efficiency of it, but it seems logical.
这篇关于ASP格式日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文