Home | Advertising Info114 USERS CURRENTLY ONLINE   
   Site Search Contact Us Wednesday, July 30, 2014  
 
 







DISCUSSION ARCHIVES
DISCUSSION ARCHIVES 2
DISCUSSION ARCHIVES 3
BLOG

 
Try a free httpZip trial now and compress for less!


We didn't realize
the site was so popular.

Other Stuff
 
 


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 - 2014 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 source code database MS SQL MS Access .mdb adovbs.inc cookies calendar codes sql commands scripts asp programming tutorials iis web server components 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