strtotime(2008-03-11 09:10:23)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gphp
Forum Commoner
Posts: 29
Joined: Sun Feb 17, 2008 1:40 pm

strtotime(2008-03-11 09:10:23)

Post by gphp »

Would anybody be helpful in explaining why these two evaluations produce different result?

Code: Select all

<?php
 
$dt = date("Y-m-d h:m:s");
 
echo "<br><br>present time:".strtotime($dt)."<br><br>";
 
    $iddate = 1205248223; // iddate: strtotime(2008-03-11 09:10:23) :( 
    echo "previous time: ".$iddate."<br><br>";
 
    $oneday = 86400;        // add one day to iddate
    $iddate = $iddate + $oneday;
 
    if($iddate > $dt){
        echo "it's time 1!<br>"; // is this wrong result!?
    }
    else{
        echo "not yet 1!<br>";
    }
 
// ---------------------------- yields different result
    $dt_1 = 1205737428;
    $iddate_1 = 1205248223;
 
    if($iddate_1 > $dt_1){
        echo "it's time 2!<br>";
    }
    else{
        echo "not yet 2!<br>";
    }
 
/*
----  result!?
 
present time:  1205741028   // bigger number!
previous time: 1205248223
 
it's time 1!
not yet 2!
 
*/
?>
gphp
Forum Commoner
Posts: 29
Joined: Sun Feb 17, 2008 1:40 pm

Re: strtotime(2008-03-11 09:10:23)

Post by gphp »

I figured it out. I forgot to convert the present date to string!? So it is working right.
:roll:
Post Reply