Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    33
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Breakdown of statement.

    I've tried to break down the following statement.

    var d=new Date();
    //So var means variable. d is the name of the variable. = is what the variable equals. duh ... new Date is a javascript function that gets the current date but I don't understand what () is?

    theDay=d.getDay(); // On this

    //theDay is the name of the next variable, d is the name of the variable i've created above and getDay turns it into a number? Still don't understand the ()

    I can get this script to work ... I just want to understand WHY i can get it work .

    Thanks in advance.
    Last edited by jake03; 08-30-2008 at 02:19 PM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,253
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    Any JavaScript book or web site will explain this.

    var d = new Date() - if no parameters are supplied within the brackets JavaScript creates an object for today's date according to the time on the local machine.

    You could also supply parameters:-
    var d = new Date(milliseconds)
    var d = new Date(dateString)
    var d = new Date(yr_num, mo_num, day_num [, hr_num, min_num,
    sec_num, ms_num])

    e.g. var d = new date(2008,7,30) // 30th August 2008

    All dates are calculated in milliseconds from 01 January, 1970 00:00:00 Universal Time (UTC) with a day containing 86,400,000 milliseconds.

    var theday = d.getDay() invokes a method of the date object which returns an integer (0 for Sunday through 6 for Saturday) representing the day of the week.

  • Users who have thanked Philip M for this post:

    jake03 (08-31-2008)

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    33
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks for your help

    Makes sense now.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •