diff --git a/reference/datetime/functions/date-add.xml b/reference/datetime/functions/date-add.xml new file mode 100644 index 0000000000..a2448815be --- /dev/null +++ b/reference/datetime/functions/date-add.xml @@ -0,0 +1,146 @@ + + + + + date_add + + Adds an amount of days, months, years, hours, minutes and seconds to a + DateTime object + + + + + &reftitle.description; + + void + date_add + + DateTime + object + + + DateInterval + object + + + + Adds the specified DateInterval object to the specified DateTime object. + + + + Works in PHP 5.3+ ONLY + + + + + + &reftitle.parameters; + + + + + object + + + + A date as returned by DateTime. + + + + + + object + + + + The amount to be added. For the date use "P3D", "P3M", "P3Y" or a + combination of the three e.g. "P2M5D" (Y = Years, M = Months, D = Days.) + MUST BE YEAR MONTH DAY FORMAT "P5Y", "P5M2D", "P5Y4D". For the time use + "T3H", "T3M", "T3S" or or a combination of the three e.g. "T5H20M" (H = + Hours, M = Minutes, S = Seconds). For dateTime us "P5D2M4YT5H20M". The + digit before the letter (NOT P or T) can be any amount. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>date_add</function> example + +format("d-m-Y H:i:s").'
'; + +date_add($date, new DateInterval("P5D")); +echo '
'.$date->format("d-m-Y").' : 5 Days'; + +date_add($date, new DateInterval("P5M")); +echo '
'.$date->format("d-m-Y").' : 5 Months'; + +date_add($date, new DateInterval("P5Y")); +echo '
'.$date->format("d-m-Y").' : 5 Years'; + +date_add($date, new DateInterval("P5Y5M5D")); +echo '
'.$date->format("d-m-Y").' : 5 Days, 5 Months, 5 Years'; + +date_add($date, new DateInterval("P5YT5H")); +echo '
'.$date->format("d-m-Y H:i:s").' : 5 Years, 5 Hours'; + +?> +]]> +
+
+
+
+ + + &reftitle.notes; + &warn.experimental.func; + + + + &reftitle.seealso; + + + date_sub + date_diff + + + + +
+ + diff --git a/reference/datetime/functions/date-sub.xml b/reference/datetime/functions/date-sub.xml new file mode 100644 index 0000000000..87194600a2 --- /dev/null +++ b/reference/datetime/functions/date-sub.xml @@ -0,0 +1,147 @@ + + + + + date_sub + + Subtracts an amount of days, months, years, hours, minutes and seconds from + a DateTime object + + + + + &reftitle.description; + + void + date_sub + + DateTime + object + + + DateInterval + object + + + + Subtracts the specified DateInterval object from the specified DateTime + object. + + + + Works in PHP 5.3+ ONLY + + + + + + &reftitle.parameters; + + + + + object + + + + A date as returned by DateTime. + + + + + + object + + + + The amount to be subtracted. For the date use "P3D", "P3M", "P3Y" or a + combination of the three e.g. "P2M5D" (Y = Years, M = Months, D = Days.) + MUST BE YEAR MONTH DAY FORMAT "P5Y", "P5M2D", "P5Y4D". For the time use + "T3H", "T3M", "T3S" or or a combination of the three e.g. "T5H20M" (H = + Hours, M = Minutes, S = Seconds). For dateTime us "P5D2M4YT5H20M". The + digit before the letter (NOT P or T) can be any amount. + + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.examples; + + + <function>date_sub</function> example + +format("d-m-Y H:i:s").'
'; + +date_sub($date, new DateInterval("P5D")); +echo '
'.$date->format("d-m-Y").' : 5 Days'; + +date_sub($date, new DateInterval("P5M")); +echo '
'.$date->format("d-m-Y").' : 5 Months'; + +date_sub($date, new DateInterval("P5Y")); +echo '
'.$date->format("d-m-Y").' : 5 Years'; + +date_sub($date, new DateInterval("P5Y5M5D")); +echo '
'.$date->format("d-m-Y").' : 5 Days, 5 Months, 5 Years'; + +date_sub($date, new DateInterval("P5YT5H")); +echo '
'.$date->format("d-m-Y H:i:s").' : 5 Years, 5 Hours'; + +?> +]]> +
+
+
+
+ + + &reftitle.notes; + &warn.experimental.func; + + + + &reftitle.seealso; + + + date_add + date_diff + + + + +
+ +