Advertisement
confs

jumlah-hari

Nov 18th, 2020 (edited)
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <ul>
  2. <?php
  3. $values = array();
  4. $values[] = array('example'=>'example1','date'=>'2020-01-25');
  5. $values[] = array('example'=>'example2','date'=>'2020-02-25');
  6. $values[] = array('example'=>'example3','date'=>'2020-03-25');
  7.  
  8. $previous = null;
  9. foreach($values as $example){
  10.     echo "<li>".$example['example']." - ".$example['date'];
  11.    
  12.     if ($previous !== null) {
  13.         $diff = strtotime($example['date'])-strtotime($previous);
  14.         echo " - ".($diff/(60*60*24))." Hari";
  15.     }
  16.    
  17.     $previous = $example['date'];
  18.     echo "</li>\n";
  19. }
  20.  
  21. ?>
  22. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement