Classic ASP - format date

故事扮演 提交于 2020-01-24 22:45:49

问题


I have a date being extracted from the database which is formatted as following

12/23/2005

Which is

mm/dd/yyyy

I want to convert it in classic asp to the following

December 23 2004

Could anyone help me with this?

Cheers,


回答1:


You could try this:

Function FormatDate(input)
    FormatDate = MonthName(Month(CDate(input))) & " " & Day(CDate(input)) & " " & Year(CDate(input))
End Function
Response.Write(FormatDate("12/23/2005"))

I'm assuming you want it to show "December 23 2005" if you want it to show "December 23 2004" then just subtract one from the Year() call:

FormatDate = MonthName(Month(CDate(input))) & " " & Day(CDate(input)) & " " & (Year(CDate(input))-1)



回答2:


assuming you are doing this in c#

DateTime thisDate = new DateTime.Now;
String outString = thisDate.ToString("MMMM dd, yyyy");


来源:https://stackoverflow.com/questions/18981624/classic-asp-format-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!