Add months to a Date in PHP

Description

The following code shows how to add months to a Date.

Example


<?php//w  w w .  j a v  a 2s. c  o  m

$date = new Date();
$date->setDMY(28,4,2010);
$date->addMonths(9);
$dcs = $date->getArray();
print_r($dcs);

?>




















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone