nathan schmoll's
aspdiscovery

back to main page

e-mail me








Formatting dates and displaying them
So you want to display the date and you don't want to deal with the inaccuracies and incompatibilities of JavaScript? There is one easy solution. ASP delivers dates in numbers, so we need to use a little extra code to turn those numbers into weekday names and month names. Here is how we display the date in the format of "Monday, September 1, 1997":

<%
response.write weekdayname(weekday(date))
response.write ",&nbsp;"
response.write monthname(month(date))
response.write "&nbsp;"
response.write day(date)
response.write ",&nbsp;"
response.write year(date)
%>

The response.write ",&nbsp;" means that it is going to write a comma and then a space. That will end up between the day name and the month name as well as between the day number and the year number.

You can go through the code and modify this code to put it in a different order and make it however you like.

copyright © 2001, nathan schmoll. all rights reserved. questions? comments? suggestions? e-mail me!