Home | Advertising Info390 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Wednesday, January 15, 2025  


Formating Date & Time




Often when using ASP or Active Server Pages you will find it necessary to format the way your date and time variables are displayed. Luckily there is a built in vbscript function called
FormatDateTime that does all the work for you.

Here are some simple examples of using the functions with your variables.
Run these from any ".asp" page and watch what happens

<%= FormatDateTime(Date) %><br>
<%= FormatDateTime(Date, 0) %><br>
<%= FormatDateTime(Date, 1) %><br>
<%= FormatDateTime(Date, 2) %><br>
<%= FormatDateTime(Now, 3) %><br>
<%= FormatDateTime(Now, 4) %><br>
<%= FormatDateTime(Now) %><br>

You should get values similar to this.
(They will be based on the current date when you run them though.)

4/18/2005
4/18/2005
Monday, April 18, 2005
4/18/2005
2:08:24 PM
14:08
4/18/2005 2:08:24 PM


In case you are wondering the date formats will adjust based on the regional or LCID settings of your web server. These examples are using USA format.



Then, in the examples below we use some of the built in Vbscript Constants with the function.
(it really does the same thing as the number values, but these are easy to remember)

<%= FormatDateTime(Date) %><br>
<%= FormatDateTime(Date, vbGeneralDate) %><br>
<%= FormatDateTime(Date, vbLongDate) %><br>
<%= FormatDateTime(Date, vbShortDate) %><br>
<%= FormatDateTime(Now, vbLongTime) %><br>
<%= FormatDateTime(Now, vbShortTime) %><br>
<%= FormatDateTime(Now) %><br>


Again, click here for more info on the
FormatDateTime function.
 

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2025 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP programs help tutorial tutorials routine routines jobs listserve mailinglist bulletin board bulletin boards programming snippet snippets CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com