我需要在“下一个提醒日期”字段中获得下一年约1天的日期&日期是由“加入日期”中的datepicker选择的..基于加入Datepicker需要明年日期减少1天....请帮帮我
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Visit Form</title>
<link rel="stylesheet" type="text/css" href="css/view.css" media="all">
<script type="text/javascript" src="javascript/view.js"></script>
<script type="text/javascript" src="javascript/calendar.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<style style="text\css">
body {
background-image: url("formbg.jpg");
background-position: 50% 50%;
background-repeat: repeat;
}
</style>
<body id="main_body" >
<div id="form_container">
<form id="form_1140107" class="appnitro" method="post" action="">
<br><span style="float:right;"><a href="logout.php" ><input type="button" value="Logout" /></a></span>
<div class="form_description">
<center><h2><a>Welcome</a></h2></center>
<br>
<center></center>
</div>
<ul >
<li id="li_3" >
<label class="description" for="element_3">Customer Id</label>
<div>
<input id="element_3" name="client" class="element text medium" type="text" maxlength="255" value="<?php echo(rand(10,100));?>"/>
</div>
</li>
<li id="li_1" >
<label class="description" for="element_1">Joining Date:</label>
<div>
<input type="text" name="date" id="datepicker" />
</div>
</li>
<li id="li_1" >
<label class="description" for="element_1">Next Renewal Date:</label>
<div>
<input type="text" name="date" value="" />
</div>
</li>
<li id="li_1" >
<label class="description" for="element_1">Reminder Date:</label>
<div>
<input type="text" name="date" id="datepicker3" />
</div>
</li>
<script>
$(function() {
$("#datepicker").datepicker({
onSelect: function(dateText, inst) {
var dateAsString = dateText; //the first parameter of this function
alert(dateAsString);
}
});
});
</script>
<!--
--><li id="li_3" >
<label class="description" for="element_3">Customer Name:</label>
<div>
<input id="element_3" name="client" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_3" >
<label class="description" for="element_3">Mobile No:</label>
<div>
<input id="element_3" name="client_name" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li id="li_4" >
<label class="description" for="element_4">Email:</label>
<div>
<input id="element_4_1" name="address" class="element text large" value="" type="text">
</div>
</li>
<li id="li_10" >
<label class="description" for="element_10">Status</label>
<div>
<select class="element select medium" id="element_10" name="status">
<option value="" selected="selected"></option>
<option value="Pending" >Pending</option>
<option value="Closed" >Closed</option>
</select>
</div>
</li>
<li id="li_9" >
<label class="description" for="element_9">Amount:</label>
<div>
<input id="element_9" name="total_cost" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li class="buttons">
<input type="hidden" name="form_id" value="1140107" />
<center><input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" /></center><br>
</li>
</ul>
</form>
</div>
</body>
</html>
答案 0 :(得分:0)
试试这段代码。 今天的日期是x
var x = new Date()
x.setFullYear(x.getFullYear()+1)
x.setDate(x.getDate()-1)
console.log(x);
答案 1 :(得分:0)
这是你的代码。只需运行代码并查看答案
<?php
$StaringDate=date('Y-m-d');
$newEndDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($StaringDate)) . " + 1 year"));
print('Next Reminder Date ' . date('Y-m-d', strtotime('-1 day', strtotime($newEndDate ))));
?>
答案 2 :(得分:0)
令人惊讶的是,我的工作时间比我应对的时间长一点。
我参与了“下次续订”和“提醒”日期(看到它需要在评论续订前15天)
我启发了我对两个答案的回答:
https://stackoverflow.com/a/11139802/2159528
https://stackoverflow.com/a/13459946/2159528
$("#datepicker3").datepicker({dateFormat: "mm/dd/yy",});
$("#datepicker2").datepicker({dateFormat: "mm/dd/yy",});
function pad(s) { return (s < 10) ? '0' + s : s; }
$("#datepicker").datepicker({
dateFormat: "mm/dd/yy",
onSelect: function(dateText, instance) {
d2 = $.datepicker.parseDate(instance.settings.dateFormat, dateText, instance.settings);
d2.setDate(d2.getDate() - 1);
d2.setFullYear(d2.getFullYear() + 1);
//alert(date2);
d3 = $.datepicker.parseDate(instance.settings.dateFormat, dateText, instance.settings);
d3.setDate(d3.getDate() - 15);
d3.setFullYear(d3.getFullYear() + 1);
//alert(date2);
date2 = [pad(d2.getMonth()+1), pad(d2.getDate()), d2.getFullYear()].join('/');
date3 = [pad(d3.getMonth()+1), pad(d3.getDate()), d3.getFullYear()].join('/');
//alert (date2);
$("#datepicker2").datepicker("setDate", date2);
$("#datepicker3").datepicker("setDate", date3);
}
});