RE: [PHP] adding days to a given date

2004-03-31 Thread Hawkes, Richard
You'll want to do something like this:

  $timeStamp = strtotime(2004-04-29);
  $timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
  $newDate = date(Y-m-d, $timeStamp); 

The 'strtotime' function converts all sorts of standard dates to the Unix
Epoch seconds (seconds since 1/1/1970). You then just add the required
seconds!

Cheers
Richard



-Original Message-
From: Merlin [mailto:[EMAIL PROTECTED]
Sent: 31 March 2004 10:01
To: [EMAIL PROTECTED]
Subject: [PHP] adding days to a given date


Hi there,

I am trying to add days to a given day, but somehow I am lost in all the time
functions.
This should be a standard function. Maybe someone has a good hint for me?

This is the given day:
2004-04-29
I would like to add 2 days to it.
So php should anyhow now how many days April has to result in this:
2004-04-30
2004-05-1

Thank you for any helpful hint,

merlin

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



Re: [PHP] adding days to a given date

2004-03-31 Thread Jason Wong
On Wednesday 31 March 2004 17:08, Hawkes, Richard wrote:
 You'll want to do something like this:

   $timeStamp = strtotime(2004-04-29);
   $timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
   $newDate = date(Y-m-d, $timeStamp);

 The 'strtotime' function converts all sorts of standard dates to the Unix
 Epoch seconds (seconds since 1/1/1970). You then just add the required
 seconds!

strtotime() can do more than that, time to RTFM.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
QOTD:
My life is a soap opera, but who gets the movie rights?
*/

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



RE: [PHP] adding days to a given date

2004-03-31 Thread Hawkes, Richard
What else can it do other than convert dates to time strings Jason? 

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: 31 March 2004 10:13
To: [EMAIL PROTECTED]
Subject: Re: [PHP] adding days to a given date


On Wednesday 31 March 2004 17:08, Hawkes, Richard wrote:
 You'll want to do something like this:

   $timeStamp = strtotime(2004-04-29);
   $timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
   $newDate = date(Y-m-d, $timeStamp);

 The 'strtotime' function converts all sorts of standard dates to the Unix
 Epoch seconds (seconds since 1/1/1970). You then just add the required
 seconds!

strtotime() can do more than that, time to RTFM.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
QOTD:
My life is a soap opera, but who gets the movie rights?
*/

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



Re: [PHP] adding days to a given date

2004-03-31 Thread Merlin
thanx Richard, that works excellent.

Merlin

Richard Hawkes wrote:

You'll want to do something like this:

  $timeStamp = strtotime(2004-04-29);
  $timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
  $newDate = date(Y-m-d, $timeStamp); 

The 'strtotime' function converts all sorts of standard dates to the Unix
Epoch seconds (seconds since 1/1/1970). You then just add the required
seconds!
Cheers
Richard


-Original Message-
From: Merlin [mailto:[EMAIL PROTECTED]
Sent: 31 March 2004 10:01
To: [EMAIL PROTECTED]
Subject: [PHP] adding days to a given date
Hi there,

I am trying to add days to a given day, but somehow I am lost in all the time
functions.
This should be a standard function. Maybe someone has a good hint for me?
This is the given day:
2004-04-29
I would like to add 2 days to it.
So php should anyhow now how many days April has to result in this:
2004-04-30
2004-05-1
Thank you for any helpful hint,

merlin

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


[PHP] adding days to a given date

2004-03-31 Thread Merlin
Hi there,

I am trying to add days to a given day, but somehow I am lost in all the time 
functions.
This should be a standard function. Maybe someone has a good hint for me?
This is the given day:
2004-04-29
I would like to add 2 days to it.
So php should anyhow now how many days April has to result in this:
2004-04-30
2004-05-1
Thank you for any helpful hint,

merlin

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


RE: [PHP] adding days to a given date

2004-03-31 Thread Harish

The time function available in PHP can be used for your requirement/

$two_days_later = date(Y-m-d,mktime(0,0,0,$month,$day+2,$year));

where $month, $day and $year are the respective parts of the given day

$year=2004
$month=04
$day=29

You can specify the number of days to be +/- in the mktime function, like its 
specified above.
You can also +/- the months and year if necessary.


regards
Harish

-Original Message-
From: Merlin [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 2:31 PM
To: [EMAIL PROTECTED]
Subject: [PHP] adding days to a given date


Hi there,

I am trying to add days to a given day, but somehow I am lost in all the time 
functions.
This should be a standard function. Maybe someone has a good hint for me?

This is the given day:
2004-04-29
I would like to add 2 days to it.
So php should anyhow now how many days April has to result in this:
2004-04-30
2004-05-1

Thank you for any helpful hint,

merlin

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




Re[2]: [PHP] adding days to a given date

2004-03-31 Thread Richard Davey
Hello Richard,

Wednesday, March 31, 2004, 10:14:39 AM, you wrote:

JW strtotime() can do more than that, time to RTFM.

RH What else can it do other than convert dates to time strings Jason?

I have to agree with Jason on this one - the following code is just
reinventing the wheel:

$timeStamp = strtotime(2004-04-29);
$timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
$newDate = date(Y-m-d, $timeStamp);

This is a very long winded way of getting the resulting date when you
can simply do this:

$newDate = strtotme(+7 day, time());

If you want it based on the current time the above will work, or just
replace time() with any other valid timestamp you may have.

Look at the manual entry for it for lots of other examples.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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