At 08:33 PM 1/15/2005, you wrote:
Torsten,
Whatever the combination, it echos "February 02-2005<br>February 02-2005<br>February 02-2005". What is wrong with it?
<?php
$week5 = "2005-02-14";
$firstDayTs = strtotime($week5);
$lastDayTs = $firstDayTs + (4 * 86400);
echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . date('Y',$firstDayTs) ."<br>";
echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . date('Y',$lastDayTs) ."<br>";
?>
John
It is outputing what you are asking it to: F A full textual representation of a month, such as January or March m Numeric representation of a month, with leading zeros Y A full numeric representation of a year, 4 digits This is all documented at: http://us2.php.net/manual/en/function.date.php
First you are asking for the Month as a name, then the month as a number then the year as a number. If you made $week5=2005-12-31 it would give you the following output:
December 12-2005<br>December 12-2006<br>
If you are wanting to make it echo "February 14-18", then check out the 3rd echo statement in the below example.
<?php
$week5 = "2005-02-14";
$firstDayTs = strtotime($week5);
$lastDayTs = $firstDayTs + (4 * 86400);
echo date('F', $firstDayTs) . ' ' . date('d', $firstDayTs) . '-' . date('Y',$firstDayTs) ."<br>\n";
echo date('F', $lastDayTs) . ' ' . date('d', $lastDayTs) . '-' . date('Y',$lastDayTs) ."<br>\n";
echo date('F', $lastDayTs) . ' ' . date('d', $firstDayTs) . '-' . date('d',$lastDayTs) ."<br>\n";
echo "\n";
?>
Now, the problem with that is that if your $week5="2005-02-18" then your results will be wrong....unless this is what you want, but the answer will be "February 28-04". You are outputing the Month from $week5, the day from $week5 and the day+4 of $week5 which takes it into the next month.
Steve
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php