ok so i believe that i should know this but i have not really dove into dates with php. Ok so what i am trying to do is find the latest date between 2 dates. And if the dates are the same then find the latest time then echo out the the latest file

$fileonedate = date("m/d/Y",filemtime("page1.php"));

$filetwodate = date("m/d/Y",filemtime("page2.php"));

$fileonetime = date("H:i:s",filemtime("page1.php"));

$filetwotime = date("H:i:s",filemtime("page2.php"));

thanks in advance

Compare the filetimes, then format the one you want to have.

$format = 'm/d/Y H:i:s';
if ($t1 = filemtime('page1.php') < ($t2 = filemtime('page2.php'))
  $filetime = date( $format, $t2 );
else
  $filetime = date( $format, $t1 );

hmmm. i thought it would be a little harder than that. thanks

so lets say that i was going to grab edit dates within the database would i do the same thing

$dateone = "03/13/2011 3:24:32";
$datetwo = "03/13/2011 3:54:21";

if ($dateone > $datetwo)
{
echo "Date one";
}else{
echo "Date two";
}

that seems to work but i just want to make sure that im doing it correctly.

What are "edit dates"?
And no, the comparison operators < = > in PHP do string or numeric comparison but not date formats. So you have to format the dates to be compared in the order Y-m-d H:m:i.

a edit date is when someone has edited the DB entry. i capture the time and put it to the DB.

ok so if i understand i have to save the dates like this (im not sure what the m is in H:m:i i think you mean H:i:s )

$dateone = "2011/03/13 15:24:32";
$datetwo = "2011/03/13 15:54:21";

if ($dateone > $datetwo)
{
echo "Date one";
}else{
echo "Date two";
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.