Skip to content

Instantly share code, notes, and snippets.

@AmineKwest
Last active May 24, 2018 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmineKwest/bb404d63e9f1d283e64b18818033dd03 to your computer and use it in GitHub Desktop.
Save AmineKwest/bb404d63e9f1d283e64b18818033dd03 to your computer and use it in GitHub Desktop.
BACK TO THE FUTURE
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<title>BACK TO THE FUTURE</title>
<style>
table,
td {
border: 1px solid #333;
text-align: center;
}
thead,
tfoot {
background-color: #333;
color: #fff;
}
p{
text-align:justify;
font-style: italic;
font-size: 20px;
margin-left: 100px;
margin-right: 100px;
}
</style>
</head>
<body>
<p>
<?php
$Doc = new TimeTravel("31-12-1985", "");
echo "Suite à une expérience ratée avec sa nouvelle machine,
le 31 décembre 1985, Doc s'est retrouvé projeté dans le temps.
D'après les notes qu'il a laissées, Marty en déduit qu'il a été projeté
le ".$Doc->findDate("PT1000000000S").".";
echo "</br>";
$Marty= new TimeTravel("23-04-1954 10:35:20", "31-12-1985 06:35:18");
$date1= "23-04-1954 06:35";
$date2= "31-12-1985 06:35";
echo $Marty->getTravelInfo($date1,$date2)." qui sépare Marty et Doc.";
echo "</br>"."Marty a retrouvé Doc mal en point.
Il faut le ramener au plus vite à notre époque pour le soigner.
Mais le réservoir de la Dolorean est endommagé.
Après une rapide expertise, Doc estimes que
la voiture ne peut plus faire des bonds dans le temps que, au mieux,
d’1 mois plus 1 semaine et 1 jour.
Il faudra refaire le plein de combustible à chaqu'une des date suivantes:";
$Marty->backToFutureStepByStep("P1M8D");
?>
</p>
<?php
class TimeTravel
{
public $start;
public $end;
public $interval;
public function __construct($start, $end){
$this->start = new DateTime($start);
$this->end = new DateTime($end);
}
public function getTravelInfo(){
if ($this->start < $this->end) {
return $this->end->diff($this->start)->format("Il y a %y années,
%m mois, %d jours, %h heures, %i minutes et %s secondes");
}
}
public function findDate($interval){
$this->interval = new DateInterval($interval);
return ($this->start->sub($this->interval)->format('d/m/Y h:i:s'));
}
public function backToFutureStepByStep($step){
$i=1;
$step = new DateInterval($step);
$stop = new DatePeriod($this->start, $step, $this->end);
foreach ($stop as $date){
?><div class="col-xs-2 col-md-2 ">
<table>
<thead>
<tr>
<th colspan="2">Date number <?php echo $i++;?></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><?php echo $date->format('M d Y A g:i');?></td>
</tr>
</tbody>
</table>
</br>
</div>
<?php
}
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment