Calendar Date Issues


#1

I am wishing to show dates on our internal website that based off of today’s date will show 3/7/30/90 days in advance

IE - Today’s date is 2012-04-03

3days = 2012-04-06
7days = 2012-04-07
30days = 2012-05-03
90days = 2012-07-02

And then be able to use the said date value in an string later on, but I can’t figure out how to illustrate days in advance??!?!?!?
Any and all help would be greatly appreciated


#2

Use strtotime(). I did a project just like that, ill post the code when I get home.


#3

ok, here you go

user input
(not the entire form)

<div style="float: left; width: 100px; margin-right: 5px;">Start Date:</div>
	<div style="float: left; text-align: left;"><input name="sdate" type="text" tabindex="1" /></div>
	<div style="float: left; width: 100px; margin-right: 5px;">Run For:</div>
	<div style="float: left; text-align: left;">
		<select name="runfor">
			<option value="0">Daily</option>
			<option value="1">1 Week</option>
			<option value="2">2 Weeks</option>
			<option value="3">Month</option>
			<option value="4">Stop</option>
		</select>
	</div>

php part (on the same page)
[php]
if(isset($_POST[‘addsub’])) {
$name = cleaner(mysql_real_escape_string($_POST[‘name’]));
$desc = cleaner(mysql_real_escape_string($_POST[‘desc’]));
$date = $_POST[‘sdate’];
$tdate = explode(’/’, $_POST[‘sdate’]); //break down user timestamp
$udate = mktime(0,0,0,$tdate[0],$tdate[1],$tdate[2]); //unix timestamp
$price = $_POST[‘price’];
$emp = $_POST[‘emp’];
$runfor = $_POST[‘runfor’];

if($_POST['n_runfor'] != 4) {
	$active = 1;
}
switch($_POST['runfor']) {
	case '0':
		$ndate = strtotime('+1 day', $udate);
		break;
	case '1':
		$ndate = strtotime('+7 days', $udate);
		break;
	case '2':
		$ndate = strtotime('+14 days', $udate);
		break;
	case '3':
		$now = time();
		$then = date("t", $now);
		$leap = date('L', $now);
		if($then == 31) {
			$ndate = strtotime('+31 days', $udate);	
		} elseif($then == 30) {
			$ndate = strtotime('+30 days', $udate);
		}
		if($then == 28 && $leap == 0) {
			$ndate = strtotime('+28 days', $udate);
		} else {
			$ndate = strtotime('+29 days', $udate);
		}
		break;
	case '4':
		$ndate = strtotime('-10 days', $udate);
		$active = 0;
		break;
}
$ins = mysql_query("INSERT INTO specials VALUES('', '$name', '$desc', '$udate', '$ndate', '$price', '$emp', '$runfor', '$active')") or die(mysql_error());
if($ins) {
	$msg = "<div style='color: #3CF; text-align: center; width: 100%;'>$name has been added</div><br />";
}

}?>[/php]