Forum Moderators: coopster

Message Too Old, No Replies

date and mktime function usage?

         

suresheva31

4:47 pm on Dec 13, 2004 (gmt 0)

10+ Year Member



Guys,

How come its not printing out the right date output. Could some tell me please, where I am making mistakes.

PHP Code:
$tomorrow = mktime(0.0,0, date("m") , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);

echo "$tomorrow<BR>";
echo "$lastmonth<BR>";
echo "$nextyear<BR>";

output:
1280289612
1100322000
1134450000

Thanks in advance

Suresh

helenp

4:56 pm on Dec 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



not sure, but try this:
print date('Y-m-d',$tomorrow).

RonPK

4:58 pm on Dec 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what you're expecting, but this seems like a typo:

$tomorrow = mktime(0.0,0, [..]

should be

$tomorrow = mktime(0,0,0, [..]

suresheva31

5:01 pm on Dec 13, 2004 (gmt 0)

10+ Year Member



thanks...works..great

dcrombie

12:56 pm on Dec 15, 2004 (gmt 0)



You might find it more intuitive to use:

$tomorrow = strtotime("tomorrow"); 
$lastmonth = strtotime("-1 month");
$nextyear = strtotime("+1 year");

;)