Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sandyarmstrong/396244 to your computer and use it in GitHub Desktop.
Save sandyarmstrong/396244 to your computer and use it in GitHub Desktop.
<?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