asp-classic – ASP格式化日期
发布时间:2020-12-16 07:36:59 所属栏目:asp.Net 来源:网络整理
导读:您好,我正在尝试在ASP中获取日期以特定格式显示(yyyymmdd).这是我到目前为止所尝试的但没有运气.任何帮助表示赞赏.谢谢 tr tdbCall Date/b/td % for i = -6 to 0 % td align=center a href="20a.asp?cldate=% response.write(DateTime.Date()+i.ToString("yy
您好,我正在尝试在ASP中获取日期以特定格式显示(yyyymmdd).这是我到目前为止所尝试的但没有运气.任何帮助表示赞赏.谢谢
<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> 解决方法
您可以使用以下功能:
Year(Now) '' Year in 4 digits Month(Now) '' Month without leading zero Day(Now) '' Day of the month without leading zero DateAdd("d",<numofdays>,Now) '' add a number of days to your date 阅读有关这些(和其他日期函数)函数here的更多信息. 如果您需要添加前导零: function addLeadingZero(value) addLeadingZero = value if value < 10 then addLeadingZero = "0" & value end if end function 你的案例就是: Dim today,myDate today = Now for i = -6 to 0 myDate = DateAdd("d",i,today) response.write "<a href=""20a.asp?cldate=" & Year(myDate) & addLeadingZero(Month(myDate)) & addLeadingZero(Day(myDate)) & """ target=""_blank"">X</a>" next (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – jQuery的ajax正在导致FireFox的全页刷新
- [你必须知道的.NET] 第一回:恩怨情仇:is和as
- 表格在asp.net中提交
- asp.net-core – 项目’XXXXXX’没有锁文件.请运行“dotnet
- 清除ASP.NET临时程序集而不重新启动IIS
- ASP.NET Core项目目录结构介绍
- asp.net-mvc – ViewBag.Title值覆盖ASP.NET MVC编辑器模板
- asp.net-mvc – EntityFramework代码在部署到Azure后未运行
- asp.net-mvc – 捕获路由错误
- asp.net-mvc-3 – VSTS错误SerializationException
推荐文章
站长推荐
- asp.net-mvc – asp.net mvc url action忽略旧参
- asp.net-mvc – Kendo UI Grid ASP.NET MVC Wrap
- asp.net-web-api – spotify请求的限制
- 通过缓存,ThreadStatic等降低ASP.NET中的初始化频
- asp.net-mvc-3 – 有没有办法通过html.actionlin
- asp.net-mvc – ASP.NET MVC 4 Web Api和REST经典
- asp.net-mvc – ASP MVC中的“@”是什么意思/做什
- asp-classic – 从头开始??在Visual Studio 2010
- 【.Net码农】认识ASP.NET MVC的5种Authorization
- asp.net-mvc – 有没有办法让RoutePrefix以可选参
热点阅读