@@ 300-321 (lines=22) @@ | ||
297 | * |
|
298 | * @return bool|Date this object for chaining, or false on failure |
|
299 | */ |
|
300 | public function add($interval = null) |
|
301 | { |
|
302 | if ( ! $interval instanceOf DateInterval) |
|
303 | { |
|
304 | if (is_numeric($interval)) |
|
305 | { |
|
306 | $delta = intval($interval); |
|
307 | $interval = new DateInterval('PT'.strval(abs($delta)).'S'); |
|
308 | if ($delta < 0) |
|
309 | { |
|
310 | $interval->invert = 1; |
|
311 | } |
|
312 | } |
|
313 | } |
|
314 | ||
315 | if ($this->datetime->add($interval)) |
|
316 | { |
|
317 | return $this; |
|
318 | } |
|
319 | ||
320 | return false; |
|
321 | } |
|
322 | ||
323 | /** |
|
324 | * Subtracts an amount of days, months, years, hours, minutes and seconds to the object |
|
@@ 330-351 (lines=22) @@ | ||
327 | * |
|
328 | * @return bool|Date this object for chaining, or false on failure |
|
329 | */ |
|
330 | public function sub($interval = null) |
|
331 | { |
|
332 | if ( ! $interval instanceOf DateInterval) |
|
333 | { |
|
334 | if (is_numeric($interval)) |
|
335 | { |
|
336 | $delta = intval($interval); |
|
337 | $interval = new DateInterval('PT'.strval(abs($delta)).'S'); |
|
338 | if ($delta < 0) |
|
339 | { |
|
340 | $interval->invert = 1; |
|
341 | } |
|
342 | } |
|
343 | } |
|
344 | ||
345 | if ($this->datetime->sub($interval)) |
|
346 | { |
|
347 | return $this; |
|
348 | } |
|
349 | ||
350 | return false; |
|
351 | } |
|
352 | ||
353 | /** |
|
354 | * Alter the timestamp of a Date object by incrementing or decrementing |