Created
May 10, 2010 16:35
-
-
Save sandyarmstrong/396244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function GetPregnancyWeekString($start_date_str) | |
{ | |
$current_week_num = floor((strtotime("now") - strtotime($start_date_str))/60/60/24/7)+1; | |
$suffix = "th"; | |
if ($current_week_num%10 == 1) | |
$suffix = "st"; | |
else if ($current_week_num%10 == 2) | |
$suffix = "nd"; | |
else if ($current_week_num%10 == 3) | |
$suffix = "rd"; | |
return "<span class=\"week_num\">$current_week_num</span>$suffix"; | |
} | |
?> | |
<div class="week_box">We're in our <?php print GetPregnancyWeekString("08/01/2009");?> week!</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment