Date and Time

javascript United Kingdom
  • 18 years ago

    A fast response to this would be helpful, its for an AVCE (what used to be GNVQ).


    Does anyone know how I can retreve the date and (slightly more importantly) the time from the system clock of someone vewing a webpage, so that the site can be programmed to comment: eg: tells them to go to bed if the clock says "3am" or says happy christmas if the date is december 25th.


    phil
    [email protected]


    Thanks a lot

  • 18 years ago

    Code:
    <SCRIPT LANGUAGE="JAVASCRIPT">
    var now = new Date;


    //Months are 0 (January) to 11 (December)
    var month = now.getMonth();
    var date = now.getDate();
    var hour = now.getHours();
    var minutes = now.getMinutes();
    </SCRIPT>

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski