Page 1 of 1

date crazy

Posted: Thu Nov 13, 2003 1:28 am
by darcher
how can i do something like this

Code: Select all

$FromDate = "01/06/2004";

if ($FromDate > "01/04/2004") 
 { then something}

Posted: Thu Nov 13, 2003 2:26 am
by Paddy
A good start is here

http://au2.php.net/manual/en/function.mktime.php

What you need to do is convert the dates you have into a unix timestamp. Then you can do a comparison between the two using your if statement.

Or at least that is how I would do it. Some guru here may say otherwise. :)

Posted: Thu Nov 13, 2003 3:06 am
by darcher
can i do something like this?

Code: Select all

$date_el_FD =  explode("/" ,$FromDate);
$date_el_TD =  explode("/" ,$ToDate);


$FD =  mktime (0, 0,0 ,$date_el_FD [1], $date_el_FD [0],$date_el_FD [2]);
$TD =  mktime (0, 0,0 ,$date_el_TD [1], $date_el_TD [0],$date_el_TD [2]);

if ($FD > $TD) { then ..}

Posted: Thu Nov 13, 2003 3:08 am
by twigletmac
Have you tried it?

Mac

Posted: Thu Nov 13, 2003 3:09 am
by Paddy
Looks good to me if you are using non-US dates. Try it and find out. :)

Posted: Thu Nov 13, 2003 3:19 am
by darcher
yeah tried but coming out not really correct

by the way my date format is in dd/mm/yyyy

thanks

Posted: Thu Nov 13, 2003 3:28 am
by darcher
OK !! its fixed now, it works

thanks guys,