Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
JavaScript using Dates, JavaScript Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: JavaScript using Dates, JavaScript Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.
 JScript using String.            
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

Learn JavaScript with Examples
Learn JavaScript with hundred of short examples with code and output.
Complete_JScript_Examples.php

JScript Interview Questions & Answers
Learn JavaScript by thousands of Interview Questions & Answers.
JavaScriptQuestions/index.php

JavaScript Tutorial >> JavaScript using Dates.


     Back             Next     





Date Object in JavaScript

In JavaScript Date class is used to store and retrieve dates information. To create a JavaScript Date object we can use any of the following techniques.

Syntax for Date Object in JavaScript

new Date ( )

Above line will create a new Date object with the value of the current date and time on that PC where the browser is running.. (We'll use this technique later on to display the current date on the page) First of all we need to store the date in a variable data:

var date = new Date ( );
Result will be :

Example of Date Object in JavaScript

<script language="javascript">
  var date=new Date();
  document.write(date);
</script>  

Methods to retrieve Date values in JavaScript

Following are the methods to extract information from the Date object: in JavaScript
 
Method  of Date object Description  of JavaScript Date Object Example of JavaScript Date
getFullYear () Retrieves the year component of the date as a 4-digit number. var x = new Date();
y = x.getFullYear ();
getMonth() getMonth() Function of Date Object retrieves the month component of the date as a number from 0 to 11 (0=January, 1=February, etc) var x = new Date();
y = x.getMonth()
getDate() getDate() Function of Date Object retrieves the day-of-month component of the date as a number from 1 to 31 var x = new Date();
y = x.getDate()
getDay() getDay() Function of Date Object retrieves the day of the week component of the date as a number from 0 to 6 (0=Sunday, 1=Monday, etc) var x = new Date();
y = x.getDay()
getHours() getHours() Function of Date Object retrieves the hours component of the date as a number from 0 to 23 var x = new Date();
y = x.getHours()
getMinutes() getMinutes() Function of Date Object retrieves the minutes component of the date as a number from 0 to 59 var x = new Date();
y = x.getMinutes()
getSeconds() getSeconds() Function of Date Object retrieves the seconds component of the date as a number from 0 to 59 var x = new Date();
y = x.getSeconds()
getMilliseconds() getMilliseconds() Function of Date Object retrieves the milliseconds component of the date as a number from 0 to 999 var x = new Date();
y = x.getMilliseconds()
getTimezoneOffset() getTimezoneOffset() Function of Date Object retrieves the time difference, in minutes, between the computer's local time and GMT var x = new Date();
y = x.getTimezoneOffset()

The above JavaScript Date methods are similar to the previous section of JavaScript Tutorial [JavaScript with Objects], but they work with UTC (Universal Time Coordinated) time, or GMT..  



     Back             Next     
 

JavaScript Date Object Functions and Properties Examples



In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 200 visitors are online now