Javascript Date Object also supports Date Time functions and provides number of functions to perform Date Time comparisons, retrieving current date or time, manipulating date time output.

In JavaScript you can use Date object to perform different actions on Date Time functions. As you know JavaScript is a client end script so it performs function execution at client end. JavaScript Date object also works at client end and retrieves the date and time of the computer system where the web page is being browsed.

Retrieve Current Date Time using JavaScript

JavaScript Date object can be used directly to get the current Date Time of the system.

Syntax

Date();

Example

document.write(Date());

To work with various function of Date object you can define a variable for Date object using new keyword.

Example

var myDate = new Date();

document.write(myDate);

JavaScript Example to get current Date String Format

document.write(myDate.toDateString());

JavaScript Example to get current Time String Format

document.write(myDate.toTimeString());

JavaScript Example to retireve Local Date String Format

document.write(myDate.toLocaleDateString());

JavaScript Example to retrieve Local Time String Format

document.write(myDate.toLocaleTimeString());

Continue to next tutorial: JavaScript Date functions to learn Date functions provided by Javascript date object.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.