Advertisement
Guest User

Untitled

a guest
May 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class TimeTravel
  5. {
  6. private $start;
  7. private $end;
  8.  
  9. public function __construct($start, $end)
  10. {
  11. $this->start = new DateTime($start);
  12. $this->end = new DateTime($end);
  13. }
  14.  
  15. public function getTravelInfo()
  16. {
  17. 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');
  18. }
  19.  
  20. public function findDate($interval)
  21. {
  22. date_sub($this->start, date_interval_create_from_date_string($interval));
  23. return date_format($this->start, 'd-m-Y');
  24. }
  25. public function backToFutureStepByStep($step)
  26. {
  27. $intervalle =date_interval_create_from_date_string($step);
  28. $steps = new DatePeriod($this->start, $intervalle ,$this->end);
  29.  
  30. foreach($steps as $date) {
  31. echo $date->format("M d Y A H:i") . "<br>";
  32. }
  33.  
  34. }
  35. }
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement