
Untitled
By: a guest on
Jul 14th, 2012 | syntax:
None | size: 1.21 KB | hits: 14 | expires: Never
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="utf-8">
<title>Week 1 - Activiteit 8 - Haal datum uit 14042010 int variable</title>
<style type="text/css">
span { display: inline-block; width: 200px; }
</style>
</head>
<body>
<?php
/**
* @author Dominique de Graaff
* @since 11-02-2012
*/
// Variables
$date = (int)"07042012";
// Logic Method 1 (strict to % and / only)
$day1 = $date % 100000000 / 1000000 % 1000000;
$month1 = $date % 1000000 / 10000 % 10000;
$year1 = $date % 10000;
// Logic Method 2 (using floor method)
$day2 = floor($date / 1000000);
$month2 = floor(($date % 1000000) / 10000);
$year2 = $date % 10000;
// Output
echo "<h1>Haal datum uit \"\$date = $date;\"</h1>";
echo "\t\t
<p>
<strong>Antwoorden:</strong><br/>
Methode 1: " . $day1 . "-" . $month1 . "-" . $year1 . " <br/>
Methode 2: " . $day2 . "-" . $month2 . "-" . $year2 . "
</p>\n";
?>
</body>
</html>