Ok I have some code, gleaned from the internet. So this is the case and what I am trying to acheive.
Ok Page, user enters Birthday ( not Birthdate ) So we have the data in format dd/mm saved to database, example: 30/07 to represent 30 July )
So next page user goes to , I want to format the date correctly to match what I am trying to acheieve, add corresponding ordinal ( but remove the – between dd and mm ) and not echo the yy because we never got that information in the first place.
Essentially, if when user hits this page, we know the dd and mm , I am happy to add current year as the yy ( but not to fetch yy from the db ) but instead supply it adhoc.
The script below, is from internet and takes into account leap years, but need help. I cannot just remove the year, as this gives false results ( presumably because of strtotime function )But when user added their Birthday , we did not grab the year, because we do not need it.
Code:
<?php
function getStarSign($date="")
{
$zodiac[356] = "Capricorn";
$zodiac[326] = "Sagittarius";
$zodiac[296] = "Scorpio";
$zodiac[266] = "Libra";
$zodiac[235] = "Virgo";
$zodiac[203] = "Leo";
$zodiac[172] = "Cancer";
$zodiac[140] = "Gemini";
$zodiac[111] = "Taurus";
$zodiac[78] = "Aries";
$zodiac[51] = "Pisces";
$zodiac[20] = "Aquarius";
$zodiac[0] = "Capricorn";
if (!$date) $date = time();
$dayOfTheYear = date("z",$date);
$isLeapYear = date("L",$date);
if ($isLeapYear && ($dayOfTheYear > 59)) $dayOfTheYear = $dayOfTheYear - 1;
foreach($zodiac as $day => $sign) if ($dayOfTheYear > $day) break;
return $sign;
}
$myBday = "2013-07-30"; // this needs to be in English Australian format not American English format but do not need year
$AuEnBday = date("dS-F-Y", strtotime($myBday)); // this switches the date from USA to AU date format but do not need year
?>
The above echoes:Leo 30th-July-2013
I want to echo : Leo 30th July ( the year bit can be a var on page somehow but NOT from db )
1 Answer