|
Posted by John Taylor-Johnston on 01/16/05 04:33
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
Roehr wrote:
> "John Taylor-Johnston" <taylorjo@collegesherbrooke.qc.ca> wrote in message
> news:41E9A649.83A9984C@collegesherbrooke.qc.ca...
> > I might be doing this backwards, but how do I extract the date from $week5
> and display $week5 + 4 days. I would like to create a function so when I
> pass
> >
> > echo displaydate($week5);
> >
> > it echos "February 14-18"
> >
> > $week0 = "2005-01-10";
> > $week1 = "2005-01-17";
> > $week2 = "2005-01-24";
> > $week3 = "2005-01-31";
> > $week4 = "2005-02-07";
> > $week5 = "2005-02-14";
> > $week6 = "2005-02-21";
> > $week7 = "2005-02-28";
> >
> > `Doable´? Easy enough to learn how to do?
> >
> > John
>
> Hi John,
>
> // convert your data to a timestamp:
> $firstDayTs = strtotime($week5);
>
> // add 4 days
> $lastDayTs = $firstDayTs + (4 * 86400);
>
> echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . date('m',
> $lastDayTs);
>
> Not tested. Maybe there's an easier way to do this.
>
> Regards, Torsten Roehr
--
John Taylor-Johnston
-----------------------------------------------------------------------------
"If it's not Open Source, it's Murphy's Law."
''' Collège de Sherbrooke:
ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/
- 819-569-2064
°v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures
/(_)\ Université de Sherbrooke
^ ^ http://compcanlit.ca/ T: 819.569.2064
[Back to original message]
|