www.webdeveloper.com
Results 1 to 3 of 3

Thread: Problem with date in the format mm/dd/yyyy

  1. #1
    Join Date
    May 2014
    Posts
    1

    Problem with date in the format mm/dd/yyyy

    Hey !

    I've got some problem when I try to display in my browser the current date in a mm/dd/yyy format. Here is the code that I try:

    <script>
    Var today = new Date();
    Var dd = today.getDate();
    Var mm = today.getMouth() + 1;
    Var yy = today.getFullYear();
    Alert(mm+'/'+dd+'/'+yy);
    </script>

    It seems correct for me, so I hope that you can explain to me where I get it wrong. Just remembere that I'm new to Javascript ^^

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,681
    Code:
    <script>
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth() + 1;
    var yy = today.getFullYear();
    alert(mm+'/'+dd+'/'+yy);
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Oct 2013
    Posts
    486
    To begin with, "getMouth" should probably be "getMonth". Second, get rid of capitalization on "Var" and "Alert". It will work then.

    [edit] Great minds think alike....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles