Hi i want to select a partcular date with month like if jan20-feb22 and if the date is Selected in between that i have to select a particular value like libra or arise and so on??? Just let me knw i want to create a chart for every individual...
A:
If I understand well, here's some code doing what you want (astrological stuffs are coming from this wikipedia article):
<?php
assert_options(ASSERT_ACTIVE, true);
assert_options(ASSERT_WARNING, false);
assert_options(ASSERT_BAIL, true);
assert_options(ASSERT_QUIET_EVAL, true);
$astroSign = array('Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo',
'Virgo', 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn',
'Aquarius', 'Pisces');
function getSign($date) {
global $astroSign;
$selectedDate = new DateTime($date);
$startDate = new DateTime($selectedDate->format('Y') . '-03-21');
$index = -1;
if ($startDate > $selectedDate) {
$startDate->modify('-1 year');
}
while ($selectedDate >= $startDate) {
$index = ($index + 1) % 12;
$startDate->modify('+1 month');
switch ($astroSign[$index]) {
case 'Cancer':
$startDate->modify('+2 day');
break;
case 'Scorpio':
$startDate->modify('-1 day');
break;
case 'Capricorn':
$startDate->modify('-2 day');
break;
}
}
return $astroSign[$index];
}
header('Content-type: text/plain');
assert(getSign('2009-03-21') == 'Aries');
assert(getSign('2009-04-21') == 'Taurus');
assert(getSign('2009-05-21') == 'Gemini');
assert(getSign('2009-06-20') == 'Gemini');
assert(getSign('2009-01-19') == 'Capricorn');
assert(getSign('2009-02-19') == 'Aquarius');
assert(getSign('2009-02-20') == 'Pisces');
echo "OK\n";
?>
NB: rapidly tested, furthermore, the getSign() function needs some error checking
RC
2009-12-31 12:47:20