MySQL DATETIME format comparison - is strtotime needed?

Posted by Steffan on Stack Overflow See other posts from Stack Overflow or by Steffan
Published on 2010-03-16T20:12:05Z Indexed on 2010/03/16 20:21 UTC
Read the original article Hit count: 393

Filed under:
|
|
|

I've been doing something along the lines of..

$dt1 = '1000-01-01 00:00:00'; //really some val from db
$dt2 = '1000-01-01 00:00:10'; //another val maybe db maybe formatted

if(strtotime($dt1) > strtotime($dt2){
//do something
}

Is the strtotime needed? can i do a more direct comparison on the datetime formatted strings?

i.e.

if($dt1 > $dt2){
//do something
}

Will that always work?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about datetime