----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to