W3Schools
home HOME Tutorials | References | Examples | Forum | About
Search W3Schools :

VBScript Tutorial
VB HOME
VB Introduction
VB How to
VB Where to
VB Variables
VB Procedures
VB Conditional
VB Looping
VB Summary

Examples
VB Examples

References
VB Functions
VB Keywords

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Tutorials
W3Schools Forum

Helping W3Schools

VBScript FormatDateTime Function


VBScript Reference Complete VBScript Reference

The FormatDateTime function formats and returns a valid date or time expression.

Syntax

FormatDateTime(date,format)

Parameter Description
date Required. Any valid date expression (like Date() or Now())
format Optional. A Format value that specifies the date/time format to use

Example 1

document.write("The current date is: ")
document.write(FormatDateTime(Date()))
Output:
The current date is: 2/22/2001

Example 2

document.write("The current date is: ")
document.write(FormatDateTime(Date(),1))
Output:
The current date is: Thursday, February 22, 2001

Example 3

document.write("The current date is: ")
document.write(FormatDateTime(Date(),2))
Output:
The current date is: 2/22/2001


Format Values

Constant Value Description
vbGeneralDate 0 Display a date in format mm/dd/yy. If the date parameter is Now(), it will also return the time, after the date
vbLongDate 1 Display a date using the long date format: weekday, month day, year
vbShortDate 2 Display a date using the short date format: like the default (mm/dd/yy)
vbLongTime 3 Display a time using the time format: hh:mm:ss PM/AM
vbShortTime 4 Display a time using the 24-hour format: hh:mm


VBScript Reference Complete VBScript Reference


Unlimited Disk and Transfer Hosting - New from Go Daddy!

Go Daddy

Go Daddy Unlimited Hosting is the reliable, cost-effective choice for site owners who want superior speed and reliability. Available for Linux or Windows, our Unlimited Hosting accounts come with unlimited disk space and bandwidth, 1,000 email accounts, 50 MySQL Databases, a FREE SSL Certificate and over 50 FREE downloadable applications and utilities available through our exclusive Hosting Connections. Count on the world’s largest hostname provider to keep your site up and running—even when you’re not!

Take the uncertainty out of Web hosting and let GoDaddy.com put service, performance and value back in. No matter which hosting type or plan you choose, your site receives 24/7 maintenance and protection in our world-class data center.

Virtual Dedicated, Dedicated Server and unlimited plans also available.

Save 10% on web hosting - Enter code w3tenoff at checkout




diploma   

Get Your Diploma!

W3Schools' Online Certification Program is the perfect solution for busy professionals who need to balance work, family, and career building.

The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.

The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.

The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.



Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2008 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
ASP.NET Web Hosting
ASP.NET
Web Hosting
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Download XML editor
Free Flash Website
EDUCATION
US Web Design Schools
HTML Exam