strtotime not working with TIME?
        Posted  
        
            by 
                Prashant
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Prashant
        
        
        
        Published on 2011-01-11T19:56:26Z
        Indexed on 
            2011/01/11
            20:54 UTC
        
        
        Read the original article
        Hit count: 238
        
php5
My mysql column has this datetime value, 2011-04-11 11:00:00 when I am applying strtotime then its returning date less than today,whereas it should be greater than today.
also when I am trying this strtotime(date('d/m/Y h:i A')); code, its returning wrong values. Is there any problem with giving TIME in strtotime?
Basically I want to do, is to compare my mysql column date with today's date, if its in future then show "Upcoming" else show nothing?
Please help and advise, what should I do?
Edited code
$_startdatetime = $rs['startdatetime'];
$_isUpcoming = false;
if(!empty($_startdatetime)){
    $TEMP_strtime = strtotime($_startdatetime);
    $TEMP_strtime_today = strtotime(date('d/m/Y h:i A'));
    if($TEMP_strtime_today < $TEMP_strtime){
        $_isUpcoming = true;
        $_startdatetime = date('l, d F, Y h:i A' ,$TEMP_strtime);
    }
}
And the value in $rs['startdatetime'] is 2011-04-11 11:00:00. And with this value I am getting following output.
$TEMP_strtime - 1302519600
$TEMP_strtime_today - 1314908160
$_startdatetime - 2011-04-11 11:00:00 
$_startdatetime its value is not formatted as the upcoming condition is false, so returning as is mysql value.
© Stack Overflow or respective owner