Re: [PHP] Displaying dates

2002-04-25 Thread Justin French

that wasn't the question you asked :)

there's been some nice answers for +/- > 1 month already, so i won't bother
echoing it again :)


justin french


on 25/04/02 10:21 PM, Craig Keightley ([EMAIL PROTECTED]) wrote:

> thanks, i already looked into this but does it also work with month -2, -3
> etc?
> - Original Message -
> From: "Justin French" <[EMAIL PROTECTED]>
> To: "Craig" <[EMAIL PROTECTED]>
> Sent: Thursday, April 25, 2002 1:07 PM
> Subject: Re: [PHP] Displaying dates
> 
> 
>> I strongly recommend reading the date section of the manual... it takes
> all
>> of 5 minutes, and you would have come across strtodate():
>> 
>> http://www.php.net/manual/en/function.strtotime.php
>> 
>> ... which can accept almost any English date/time phrase (like "next
>> month"), and convert it to a Unix time stamp... combined with date()'s
>> ability to accept a given timestamp (as well as the current time), you get
>> exactly what you want in three lines :)
>> 
>> 
>> > 
>> $today = date("j-M-Y H:i");
>> $next_month = date("j-M-Y H:i",strtotime("next month"));
>> $last_month = date("j-M-Y H:i",strtotime("last month"));
>> 
>> echo "Last Month: $last_month ";
>> echo "Today: $today ";
>> echo "Next Month: $next_month ";
>> 
>> ?>
>> 
>> 
>> It gets a little more complex when you're not dealing with the current
>> server time I think... but that wasn't your question.
>> 
>> 
>> Justin French
>> 
>> Creative Director
>> http://Indent.com.au
>> 
>> 
>> 
>> 
>> on 25/04/02 8:46 PM, Craig ([EMAIL PROTECTED]) wrote:
>> 
>>> How can i display a dynamic page showing last month and next month and
> the
>>> month before
>>> 
>>> eg
>>> this moth is 
>>> how do i add 1 to the month or -1 to the month?
>>> 
>>> 
>> 
>> 
> 


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




Re: [PHP] Displaying dates

2002-04-25 Thread heinisch

At 25.04.2002  11:46, you wrote:
>How can i display a dynamic page showing last month and next month and the
>month before
>
>eg
>this moth is 
>how do i add 1 to the month or -1 to the month?

Several methods

mktime() where you put last month(s) via (date("m")  -1)
getting the actual day of the month, calculating its seconds +1
substracting this from the actual time(). Vice versa for adding one month.
but I think mktime makes it easier.
Any other suggestions ?
Oliver


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