2
Contributors
1
Reply
16
Views
2 Years
Discussion Span
Last Post by minitauros
1

You should checkout the DateTime class.

Example:

<?php
$date_1 = new DateTime;
$date_2 = new DateTime;

$date_1->setDate(2015, 02, 01);
$date_1->setTime(0, 0, 0);

$date_2->setDate(2015, 02, 05);
$date_2->setTime(0, 0, 0);

$diff = $date_1->diff($date_2);
echo '$diff: ' . $diff->format('%d days') . '<br>';

// OR:
$date_1->add(new DateTimeInterval('P1Y'); // Adds 1 year to $date_1, check out the DateTimeInterval class.
echo '$date_1 is now: ' . $date_1->format('Y-m-d H:i:s') . '<br>';

Edited by minitauros

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.