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! Link to comment https://forums.phpfreaks.com/topic/67945-solved-add-50-days-to-current-date-in-this-format-mmddyyyy/ 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. Link to comment https://forums.phpfreaks.com/topic/67945-solved-add-50-days-to-current-date-in-this-format-mmddyyyy/#findComment-341675 Share on other sites More sharing options...
solarisuser Posted September 5, 2007 Author Share Posted September 5, 2007 Works great - thanks! Link to comment https://forums.phpfreaks.com/topic/67945-solved-add-50-days-to-current-date-in-this-format-mmddyyyy/#findComment-341720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.