Today's Date : Date « Development « JavaScript DHTML






Today's Date


/*
Examples From
JavaScript: The Definitive Guide, Fourth Edition

Legal matters: these files were created by David Flanagan, and are
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and
distribute them for any purpose.  Please note that these examples are
provided "as-is" and come with no warranty of any kind.

David Flanagan
*/
<html>
<head>
<title>Today's Date</title>
    <script language="JavaScript">
    // Define a function for use later on.
    function print_todays_date() {
        var d = new Date();                  // Get today's date and time
        document.write(d.toLocaleString());  // Insert it into the document
    }
    </script>
</head>
<body>
The date and time are:<br>
<script language="JavaScript">
  // Now call the function we defined above.
  print_todays_date();
</script>
</body>
</html>


           
       








Related examples in the same category

1.Demo all methods in Date class
2.how many days Between two dates
3.Display date: day month year in string
4.Date: date, month, and year.
5.Set date: setDate, setHour
6.UTC time: getUTCDate returns the Universal Coordinated Time
7.Display weekday: name of the current day
8.Display full date : complete date with the day name and month name
9.Display time: continues writing time per second.
10.Date: Week of the year
11.Display current date: year, month day in number
12.Extending the Date Object to Include Some New Methods
13.Methods and Properties of the Date Object
14.Using the Date Object
15.Output day
16.A Dynamic Welcome Message
17.How Many Days Until Christmas
18.Summer Games Countdown
19.Simple Date Validation
20.GMT Calculator
21.Days Before Next Christmas Xmas
22.Get how many days before a date