Free web development scripts for the webmasterDevelopment Scripts

 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 2 users online
 o Most users online: 67
 o Home
  o ASP
   o Miscellaneous
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o OxyScripts
 o Free Wedding Websites
 o Open Source Design
 o designplace
 o devnet
 o Wedding Vendor Directory

Effectively format dates and times with ASP (Rated 0)

Description:

Formatting the date and time into a specific format can be important, especially for posting to a database and for consistency. VBScript has a built in function called "FormatDateTime" which combined with a value for the type of date or time, can "prepare" the field for accuracy before it gets put into a database field.

There are 5 constants with associated values that can be used. 0 is vbGeneralDate, 1 is vbLongDate, 2 is vbShortDate (00/00/00), 3 is vbLongTime and 4 is vbShortTime. 1, 2 and 3 are dependent on your local machines locale settings (or regional settings) which are set in your machines control panel under "Regional Settings". As shown below, the numbers are defined after the date/time or a variable containing a date time, separated with a comma.

Code starts here


'Formatting date and time with FormatDateTime

dim strDate
dim strFormTime

strFormTime = Request.Form("time")

strDate = FormatDateTime(12-apr-02, 2)

'or via form input

strFormTime = FormatDateTime(strFormTime, 3)


Submitted by Devscripts on 13-02-2003 20:07


Rate This Script

User Contributed Comments

Registered Members login
© Copyright 2003 - Devscripts.net