Re: Strange behaviour of mktime() in objects

From: Date: Thu, 03 May 2001 15:35:06 +0000
Subject: Re: Strange behaviour of mktime() in objects
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51292@lists.php.net to get a copy of this message
----- Original Message ----- From: <heinisch@creaction.de> To: <php-general@lists.php.net> Sent: 2001. május 2. 21:34 Subject: [PHP] Strange behaviour of mktime() in objects > Hi folks, > I have to make several conversions from / to timestamp (seconds in the > UNIX-Epoche) > here you see two snippets of my code > File1 the testfile > <? /* Testpage for Class timeStuff named test_sts_timestuff.html */ > include"sts_timestuff.html"; > $STST = new timeStuff; > $wert="2001_04_20"; > $STST -> setTimeStamp($wert); > ?> > > File2 the Classfile > > <? /* Classfile named: sts_timestuff.html */ > class timeStuff > { > var $TS; > > function setTimeStamp($wert) // $wert="2001_04_20"; > { > (int)$pieces=explode("_",$wert); //even if I use (int) or not no > change in output > //show the input in pieces > for($i=0; $i < count($pieces) ; $i++) > { > echo "TIMESTAMP[$i] = $pieces[$i]<br>"; > } > > $this -> TS = mktime(12,00,00,$pieces[1],$pieces[3],$pieces[0]); you missed the indexing of the day element, you'd better write 2 instead of 3========================^ $this -> TS = mktime(12,00,00,$pieces[1],$pieces[2],$pieces[0]); > echo "TIMESTAMP in Object = ".date("H:i:s-Y-m-d",$this -> > TS)."<br>"; > > }/* end function */ > }/* end class */ > ?> > > The output is : > TIMESTAMP[0] = 2001 > TIMESTAMP[1] = 04 > TIMESTAMP[2] = 20 > TIMESTAMP in Object = 13:00:00-2001-03-31 > As you can see, the output of the pieces is correct, but the reassembling > to a date > gives a wrong date and time, (I would understand, if time is incorrect, but > the date > is absolutely out of tune) > Any ideas what this could be?? > Thanks in advance Oliver > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#51292) next »