Re: Date()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"John Taylor-Johnston" <taylorjo@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:41E9A649.83A9984C@xxxxxxxxxxxxxxxxxxxxxxxxxx
> 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux