using post Tag as variable in function
-
Mike
My problem now is using a tag set up on the post (called birthdate and storing a date in the format YYYY-MM-DD – which is equivalent to date(‘Y-m-d’)) instead of harcoding the date as below 1998-11-30each selected post whose birthday it is will have a different date.
I can’t seem to get the tag into the code if I replace the date with $birthdate I get a code error…function get_age($years) { $diff = abs(strtotime(date('Y-m-d')) - strtotime('1998-11-30')); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); $results = $years." years "; return $results; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘using post Tag as variable in function’ is closed to new replies.