Compare two dates
-
For lot of reasons (too long to explain in fact) I have several dates by post in the DB (add by myself).
So post_date, post_datedead, post_datefuture, post_datepast. I have made functions in a plugin by copying template function “the_date()”. Everything works.
My problem is I need to compare these dates, to know for example how much days there are between the 15/02/2005 and the 18/03/2005, and catch it in a variable…
I have made some mysql functions like “the_datepast_mysql()”
see :
function the_datepast_mysql() {
global $post;
echo $post->post_datedebut;
}It works. And another function to compare :
see :
function numberofdays($mmstart, $mmend) {
$tDeb = explode(“-“, $mmstart);
$tFin = explode(“-“, $mmend);$diff = mktime(0,0,0, $tFin[1], $tFin[2], $tFin[0]) –
mktime(0,0,0, $tDeb[1], $tDeb[2], $tDeb[0]);return(($diff / 86400)+1);
}
But I can’t catch a result ! … ? I can’t understand why and it’s perhaps under my nose but I can’t understand why and it’s perhaps under my nose but I can’t understand why and it’s perhaps under my nose but I can’t understand why and it’s perhaps under my nose but I can’t understand why… horrible.
- The topic ‘Compare two dates’ is closed to new replies.