solarisuser Posted September 4, 2007 Share Posted September 4, 2007 Hello, I am trying to have JavaScript read "09/04/2007" as a date value, and add 50 days to it. Do I need to split it up into a different date format? I tried adding parseInt(50) but it didnt automatically know what I'm trying to do. Any help would be appriciated - thanks! Quote Link to comment Share on other sites More sharing options...
php_tom Posted September 4, 2007 Share Posted September 4, 2007 I think this will do what you want: <script type="text/javascript"> var dateStr = "09/04/2007"; var millis = Date.parse(dateStr); var newDate = new Date(); newDate.setTime(millis + 50 *24*60*60*1000); var newDateStr = "" + (newDate.getMonth()+1) + "/" + newDate.getDate() + "/" + newDate.getFullYear(); alert(newDateStr); </script> Hope it helps. Quote Link to comment Share on other sites More sharing options...
solarisuser Posted September 5, 2007 Author Share Posted September 5, 2007 Works great - thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.