-5

I want to show the date in an alert in JavaScript.

<script type="text/JavaScript">

alert(date());

</script>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Mohcin Bahaddou
  • 11
  • 1
  • 2
  • 7

2 Answers2

1

Simply create a new Date object and pass it to alert()

<script type='text/javascript'>
   alert(new Date());
</script>
asdf
  • 2,927
  • 2
  • 21
  • 42
-1
<script type="text/JavaScript">
alert(new Date());
</script>

Learn more about Js date js date

Amir Saadallah
  • 668
  • 1
  • 8
  • 19
  • 1
    Why would you use implicit global variables or link to W3Schools _or_ answer a question that has zero research effort where the OP didn’t even do a simple Google search? – Sebastian Simon Sep 07 '15 at 23:50
  • 1
    to make him understand how we gate the date `new Date()` and the link to give him more information about the ways of instantiating a date – Amir Saadallah Sep 07 '15 at 23:56
  • 2
    @AnonyPIng—there are vastly better resources than w3schools, such as the ECMAScript standard, W3C and MDN. – RobG Sep 08 '15 at 00:17