Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['commands']) && isset($_GET['format']) && isset($_GET['date'])){
- $date = $_GET['date'];
- $outputFormat = $_GET['format'];
- $commands = $_GET['commands'];
- $date = DateTime::createFromFormat('d/m/Y', $date);
- $commands = array_map('trim', explode("\n", $commands));
- for ($i = 0; $i < count($commands); $i++) {
- $commandArgs = explode(" ", $commands[$i]);
- $value = $commandArgs[1];
- $command = $commandArgs[0];
- if($command == "add"){
- $date -> add(new DateInterval("P".$value."D"));
- }
- else{
- $date -> sub(new DateInterval("P".$value."D"));
- }
- }
- echo $date->format($outputFormat);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement