I’m new to PHP and I want to add 2 months to a specific date in an html code. How can I do it? Please guide me through,
Here’s the code I use:
private function inputExpiryDate() {
$value = $this->expiryDate;
$html = "";
$html .= '<label for="expirydate">Expiry Date:</label>';
$html .= '<input type="text" readonly name="expirydate" id="expirydate" value="'.$value.'">';
$html .= '<input type="button" id="expirydatebutton" onclick="getExpiryDate()">' . PHP_EOL;
return $html;
}
Question is how will I add this
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 month"); ??
Any help is really appreciated.
You don’t have to decompose the
$datevalue to use it when doing relative date changes. This should just work as expected: