tags:

views:

39

answers:

3

Hi,

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

A: 

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
A: 

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
A: 

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

naikus