Classic ASP - format date

2019-07-25 14:09发布

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,

标签: asp-classic
2条回答
手持菜刀,她持情操
2楼-- · 2019-07-25 15:00

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)
查看更多
唯我独甜
3楼-- · 2019-07-25 15:03

assuming you are doing this in c#

DateTime thisDate = new DateTime.Now;
String outString = thisDate.ToString("MMMM dd, yyyy");
查看更多
登录 后发表回答