0

i would really appreciate some help creating some java script that will eventually be used in Selenium that automatically sets a date 10 days ahead from the current date and displays in the following format dd/mm/yyyy.

i currently have the script below but i'm not getting anywhere with it. The parts in BOLD are what i suspect to be creating the issue.

var myDate=new Date(); myDate.now.format(myDate.setDate(myDate.getDate()+5),("dd/mm/yyyy");

Any help would be much appreciated.

Cheers

Jules

Julian
  • 381
  • 1
  • 4
  • 4
  • 1
    http://stackoverflow.com/questions/3572561/javascript-set-date-10-days-in-the-future-in-this-format-dd-mm-yyyy-e-g-21-08 you already have the same question dont know y you asked this multiple time .......... – Pranay Rana Aug 26 '10 at 07:15

3 Answers3

1

Unfortunately JavaScript doesn't support formats. There is some libraries that have the functionality. But here is what you can do:

var MyDate = new Date(),
    MyDateString;
MyDate.setDate(MyDate.getDate() + 10)
MyDateString = MyDate.getDate() + '/' + MyDate.getMonth() + '/' + MyDate.getFullYear()
alert(MyDateString)

..fredrik

fredrik
  • 17,537
  • 9
  • 51
  • 71
0

Check the following links will help you to achieve the functionality you want

A simple formatDate function for JavaScript

JavaScript Date Format

var now = new Date();

now.format("m/dd/yy");
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
0

Why not use the date.js library. Its awesome date library that should be part of a web development toolkit!

naikus
  • 24,302
  • 4
  • 42
  • 43