note 117881 added to function.date
| From: | Anonimo | Date: | Wed, 26 Aug 2015 05:56:26 +0000 |
| Subject: | note 117881 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203471@lists.php.net to get a copy of this message | ||
I think there are problems getting the day of week for year before 1900
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Equal Years</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
echo "<h1>Equal Years</h1><br/>";
function isEqualYear($year_input, $year_analize) {
$dayweek01gen_input = date("l", strtotime($year_input . "-01-01"));
$daysyear_input = $giorni = date("t",strtotime($year_input . "-02-01"));
$dayweek01gen_analize = date("l", strtotime($year_analize . "-01-01"));
$daysyear_analize = date("t",strtotime($year_analize . "-02-01"));
if ( ($dayweek01gen_analize == $dayweek01gen_input) && ($daysyear_analize ==
$daysyear_input) ) {
#echo '<div class="log">' . $year_input . ' e ' .
$year_analize . ' sono uguali</div>';
return true;
} else {
#echo '<div class="log">' . $year_input . ' e ' .
$year_analize . ' sono diversi</div>';
return false;
}
}
$year = $_REQUEST['year'];
$wanted_past = 5;
$wanted_future = 5;
$founded = 0;
$founded_array = array();
$i = 1; // usato per decrementare l'anno
// andando a ritroso cerco gli anni uguali
while ($founded != $wanted_past) {
$eq = isEqualYear($year, $year-$i);
if ($eq) {
// mettere in un array da stampare successivamente
$founded_array[$founded] = $year-$i;
$founded++;
}
$i++;
}
// stampo array anni passati uguali trovati
for ($i=count($founded_array)-1; $i>=0; $i--) {
if ($founded_array[$i] == 1582) {
echo '<a href="eccezione.php">';
}
echo $founded_array[$i];
if ($founded_array[$i] == 1582) {
echo ' *</a>';
}
echo '<br/>';
}
echo '<br/><div class="bold">';
if ($year == 1582) {
echo '<a href="eccezione.php">';
}
echo $year;
if ($year == 1582) {
echo ' *</a>';
}
echo '</div><br/>';
$founded = 0;
$founded_array = array();
$i = 1; // usato per incrementare l'anno
// andando nel futuro cerco gli anni uguali
while ($founded != $wanted_past) {
$eq = isEqualYear($year, $year+$i);
if ($eq) {
// mettere in un array da stampare successivamente
$founded_array[$founded] = $year+$i;
$founded++;
}
$i++;
}
// stampo array anni passati uguali trovati
for ($i=0; $i < count($founded_array); $i++) {
if ($founded_array[$i] == 1582) {
echo '<a href="eccezione.php">';
}
echo $founded_array[$i];
if ($founded_array[$i] == 1582) {
echo ' *</a>';
}
echo '<br/>';
}
?>
</body>
</html>
----
Server IP: 72.52.91.14
Probable Submitter: 188.153.38.248
----
Manual Page -- http://php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/117881
Del: integrated -- https://master.php.net/note/delete/117881/integrated
Del: useless -- https://master.php.net/note/delete/117881/useless
Del: bad code -- https://master.php.net/note/delete/117881/bad+code
Del: spam -- https://master.php.net/note/delete/117881/spam
Del: non-english -- https://master.php.net/note/delete/117881/non-english
Del: in docs -- https://master.php.net/note/delete/117881/in+docs
Del: other reasons-- https://master.php.net/note/delete/117881
Reject -- https://master.php.net/note/reject/117881
Search -- https://master.php.net/manage/user-notes.php