Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 14th, 2012  |  syntax: None  |  size: 1.21 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html lang="nl">
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <title>Week 1 - Activiteit 8 - Haal datum uit 14042010 int variable</title>
  6.         <style type="text/css">
  7.             span { display: inline-block; width: 200px; }
  8.         </style>
  9.     </head>
  10.     <body>
  11.         <?php
  12.         /**
  13.          * @author  Dominique de Graaff
  14.          * @since   11-02-2012
  15.          */
  16.        
  17.         // Variables
  18.         $date    = (int)"07042012";      
  19.        
  20.         // Logic Method 1 (strict to % and / only)
  21.         $day1    = $date % 100000000 / 1000000 % 1000000;
  22.         $month1  = $date % 1000000 / 10000 % 10000;
  23.         $year1   = $date % 10000;
  24.        
  25.         // Logic Method 2 (using floor method)
  26.         $day2    = floor($date / 1000000);
  27.         $month2  = floor(($date % 1000000) / 10000);
  28.         $year2   = $date % 10000;
  29.  
  30.         // Output      
  31.         echo "<h1>Haal datum uit \"\$date = $date;\"</h1>";
  32.         echo "\t\t
  33.             <p>
  34.                 <strong>Antwoorden:</strong><br/>
  35.                 Methode 1: " . $day1 . "-" . $month1 . "-" . $year1 . " <br/>
  36.                 Methode 2: " . $day2 . "-" . $month2 . "-" . $year2 . "
  37.             </p>\n";
  38.        
  39.         ?>
  40.     </body>
  41. </html>