Home | Advertising Info253 USERS CURRENTLY ONLINE   
   Site Search Contact Us Sunday, June 24, 2018  

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.)

Monday, April 18, 2005
2:08:24 PM
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 - 2018 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.

PowerASP active server pages asp.net microsoft .net framework sdk learn asp what is asp tutorial learn asp.net 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