Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class TimeTravel
- {
- private $start;
- private $end;
- public function __construct($start, $end)
- {
- $this->start = new DateTime($start);
- $this->end = new DateTime($end);
- }
- public function getTravelInfo()
- {
- return $this->start->diff($this->end)->format('Il y a %Y années, %M mois, %D jours, %h heures, %i minutes et %s secondes entre les deux dates');
- }
- public function findDate($interval)
- {
- date_sub($this->start, date_interval_create_from_date_string($interval));
- return date_format($this->start, 'd-m-Y');
- }
- public function backToFutureStepByStep($step)
- {
- $intervalle =date_interval_create_from_date_string($step);
- $steps = new DatePeriod($this->start, $intervalle ,$this->end);
- foreach($steps as $date) {
- echo $date->format("M d Y A H:i") . "<br>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement