Page 1 of 1

mktime

Posted: Sun Jul 30, 2006 11:01 am
by NiGHTFiRE
Hey,
I have two columns in my database. one column is todays date:

Code: Select all

date('Y,m,d,H,i,s');
And then one to go one month ahead:

Code: Select all

mktime(0,0,0,date("m")+1, date("d"), date("Y"));
But it's not what i want,
For example when i ran it:

from date('Y,m,d,H,i,s) :
2006,07,30,17,56,41

thats like i want it. But with

mktime(0,0,0,date("m")+1, date("d"), date("Y"));

i get: 1156888800

I want that to be: 2006, 08, 30, 17,56,41

So it just gives the result one month ahead.
Thanks.

Posted: Sun Jul 30, 2006 11:04 am
by feyd
pass the return from mktime() back to date() as the second argument.

Posted: Sun Jul 30, 2006 12:08 pm
by NiGHTFiRE

Code: Select all

$plus_start = date('Y,m,d,H,i,s');
$plus_stop = mktime(0,0,0,date("m")+1, date("d"), date("Y"));
$nyplus_stop = date($plus_stop);
That doesn't work. How should i do it?

Posted: Sun Jul 30, 2006 12:14 pm
by RobertGonzalez
NiGHTFiRE wrote:

Code: Select all

$plus_start = date('Y,m,d,H,i,s');
$plus_stop = mktime(0,0,0,date("m")+1, date("d"), date("Y"));
$nyplus_stop = date($plus_stop);
That doesn't work. How should i do it?

Code: Select all

$nyplus_stop = date('Y,m,d,H,i,s', strtotime('+1 Month'));
You may want to look at the date() function, strtotime() and mktime() functions for how they handle their passed parameters and what they return.

EDIT | Actually made my post useful instead of error laiden garbage.

Posted: Sun Jul 30, 2006 12:21 pm
by NiGHTFiRE

Code: Select all

$nyplus_stop = date('Y,m,d,H,i,s', strtotime('+1 Month');
Gives me: Parse error: parse error, unexpected ';' in /srv/www/htdocs/test.php on line 10

Posted: Sun Jul 30, 2006 12:29 pm
by bike5

Code: Select all

$nyplus_stop = date('Y,m,d,H,i,s', strtotime('+1 Month'));

Posted: Sun Jul 30, 2006 12:35 pm
by RobertGonzalez
Sorry about that. Seems I forgot a close parenthesis. :oops:

Posted: Sun Jul 30, 2006 12:41 pm
by NiGHTFiRE
Oh, and i didn't even look for that :P
Thanks anyway :)