Well here we go, I reworked it in PHP, with blank entries and the like. I didn't quite understand your formatting for the days of the month and the current day so I leave that up to you. I also stuck to the variables that you used in your code though I sorta used $my_time as a temporary variable.
<?
$offset = 0;
$my_time = time() + $offset;
?>
<h3>Calendar Log - <? echo date('F Y', $my_time); ?></h3>
<table class="calendar" border="0" cellpadding="0" cellspacing="1">
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
<?
$days = date('t', $my_time);
$day = date('j', $my_time);
$day_of_week = date('w', $my_time);
$month_start = (8 - $day % 7 + $day_of_week) % 7;
?>
<tr>
<?
for($i = 0; $i < $month_start; $i++)
{
echo '<td class="na"> </td>';
}
for($i = 1; $i <= 7 - $month_start; $i++)
{
echo '<td>';
echo $i;
echo '</td>';
}
?>
</tr>
<?
$my_time = 0;
for($i = 8 - $month_start; $i <= $days; $i++)
{
if($my_time == 0)
{
echo '<tr>';
}
echo '<td>';
echo $i;
echo '</td>';
$my_time++;
if($my_time == 7)
{
echo '</tr>';
$my_time = 0;
}
}
$my_time = ($days + $month_start) % 7;
if($my_time != 0)
{
for($i = 0; $i < 7 - $my_time; $i++)
{
echo '<td class="na"> </td>';
}
echo '</tr>';
}
?>
</table>