PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
darcher
Forum Newbie
Posts: 4 Joined: Thu Nov 13, 2003 1:28 am
Post
by darcher » Thu Nov 13, 2003 1:28 am
how can i do something like this
Code: Select all
$FromDate = "01/06/2004";
if ($FromDate > "01/04/2004")
{ then something}
Paddy
Forum Contributor
Posts: 244 Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:
Post
by Paddy » Thu Nov 13, 2003 2:26 am
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.
darcher
Forum Newbie
Posts: 4 Joined: Thu Nov 13, 2003 1:28 am
Post
by darcher » Thu Nov 13, 2003 3:06 am
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 ..}
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Nov 13, 2003 3:08 am
Have you tried it?
Mac
Paddy
Forum Contributor
Posts: 244 Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:
Post
by Paddy » Thu Nov 13, 2003 3:09 am
Looks good to me if you are using non-US dates. Try it and find out.
darcher
Forum Newbie
Posts: 4 Joined: Thu Nov 13, 2003 1:28 am
Post
by darcher » Thu Nov 13, 2003 3:19 am
yeah tried but coming out not really correct
by the way my date format is in dd/mm/yyyy
thanks
darcher
Forum Newbie
Posts: 4 Joined: Thu Nov 13, 2003 1:28 am
Post
by darcher » Thu Nov 13, 2003 3:28 am
OK !! its fixed now, it works
thanks guys,