Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date + 2 days

Status
Not open for further replies.

craigward

Programmer
Nov 13, 2007
230
GB
Hi, I’m struggling to get today’s date and add two days to it then format the result like dd/mm/yyyy I have searched google and tried so many examples I think it would confuse and raise more questions if I show them here.

Does anyone have an example of this or a link to a site that does. Would really appreciate finding the answer to this as I have spent days looking. Thanks in advance.
 
What was wrong with your last post asking the same question (thread216-1560662) where you said that the 4-line solution from Bong 'did the job perfectly'?



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
I can't get the formating to display dd/mm/yyyy and because that post was from a week back i did not think anyone would see if i added to it so i thought a simple question might make things easier all round.

If this could be tweaked to format it right that would be great.


Code:
<html>

<head>

<script type="text/javascript">
    var d = new Date();

function addDays(){

var d=new Date()
alert(d.toString())  //shows today's date
d.setDate(d.getDate()+30)
alert(d.toString()) //shows today's date plus 9 days
}
</script>

</head>

<body onLoad="addDays()">

</body>

</html>
 
Hi

For your formatting question you got answers by Bong and ggriffit in thread216-1560805. Also there you got advice for the case you have problems :
Feherke said:
[ul]
[li]Show us those codes.[/li]
[li]Show us those errors.[/li]
[/ul]
We can not help correcting your errors unless you show us those errors.

Feherke.
 
I have tried those functions and the error is always "object doesn't support property or method"

Code:
<html>

<head>

<script type="text/javascript">
var myDate = new Date();

function addDays(){

alert(myDate.format('M,d,Y'));
}
</script>

</head>

<body onLoad="addDays()">

</body>

</html>
 
Hi

Why not continue your date formatting problem in the date formatting thread you started ? The suggestions you received are there so is easier to follow the steps you (not) done.

As mentioned before, there in no format() method. You can use it only after defining it. The article suggested by Bong contains all code you need.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top