fondulac
asked on
Code needed to calculate date 1 week, 16 days, 3 weeks and 6 weeks from today
Hi,
I am needing code for our intranet website that will calculate future dates (1 week, 16 days, 3 weeks and 6 weeks) from the current day's date. It doesn't have to be PHP, but since we use Wordpress, I thought that might work best. I am not a programmer, and do not know a thing about programming languages. Therefore, any and all help/suggestions are greatly appreciated! Thanks in advance.
I am needing code for our intranet website that will calculate future dates (1 week, 16 days, 3 weeks and 6 weeks) from the current day's date. It doesn't have to be PHP, but since we use Wordpress, I thought that might work best. I am not a programmer, and do not know a thing about programming languages. Therefore, any and all help/suggestions are greatly appreciated! Thanks in advance.
This article will show you how to get elapsed time periods very easily.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
I'll show you a tested-and-working example in a moment. Best, ~Ray
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
I'll show you a tested-and-working example in a moment. Best, ~Ray
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script language="JavaScript"><!--
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
alert(addDays(new Date(),-100));
//--></script>
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
alert(addDays(new Date(),-100));
//--></script>
ASKER
I apologize for the delay in responding. I had an incredibly busy day at work. I will test your solutions as soon as I get an opportunity. I'll be sure to get back with you. Thank you!
function getDateAfterDays ( noOfDays )
{
var noOfMilliseconds = noOfDays * 24 * 60 * 60 * 1000;
var currentDateMilliseconds = new Date ().getTime();
var futureDate = new Date ( currentDateMilliseconds + noOfMilliseconds );
return futureDate;
}