10-05-2009, 11:12 AM
This will tell you the day of the week of any date you put in. I've done it to tell you the day you were born on but that's just what I initially made it for. This is something I did ages ago when I started learning PHP but this version is like a tenth the size of the original version, now that i understand mktime()
Put in your DoB and it'll say what day it was.
PHP Code:
<html>
<head>
<title>Birthday Calculator</title>
<style type="text/css">
.text {
color: #000000;
font-family: "Trebuchet MS";
}
</style>
</head>
<body>
<form method="get" action="">
<span class="text">Date:</span>
<select name="date" class="text">
<option value=""></option>
<?php
for($i=1;$i<=31;$i++)
{
?>
<option value="<?php echo $i; ?>"<?php if($_GET['date'] == $i) { echo " selected=\"selected\""; } ?>><?php echo $i; ?></option>
<?php
}
?>
</select>
<?php
$months = array("1" => "January",
"2" => "February",
"3" => "March",
"4" => "April",
"5" => "May",
"6" => "June",
"7" => "July",
"8" => "August",
"9" => "September",
"10" => "October",
"11" => "November",
"12" => "December"
);
?>
<span class="text">Month:</span>
<select name="month" class="text">
<option value=""></option>
<?php
foreach($months as $mid => $month)
{
?>
<option value="<?php echo $mid; ?>"<?php if($_GET['month'] == $mid) { echo " selected=\"selected\""; } ?>><?php echo $month; ?></option>
<?php
}
?>
</select>
<span class="text">Year:</span>
<select name="year" class="text">
<option value=""></option>
<?php
for($i=2009;$i>=1900;$i--)
{
?>
<option value="<?php echo $i; ?>"<?php if($_GET['year'] == $i) { echo " selected=\"selected\""; } ?>><?php echo $i; ?></option>
<?php
}
?>
</select>
<input type="submit" class="text" value="Submit" />
</form>
<?php
if($_GET)
{
foreach($_GET as $key => $val)
{
$_GET['$key'] = htmlspecialchars($val);
}
$day_of_week = date("l", mktime(0, 0, 0, $_GET['month'] , $_GET['date'] , $_GET['year']));
echo "<span class=\"text\">You were born on a " . $day_of_week . "</span>";
}
?>
</body>
</html>
Put in your DoB and it'll say what day it was.