Author Topic: [SOLVED] comparing date  (Read 445 times)

0 Members and 1 Guest are viewing this topic.

Offline localhost1Topic starter

  • Irregular
  • Posts: 37
    • View Profile
[SOLVED] comparing date
« on: September 25, 2007, 03:34:49 AM »
hi!
i have requested the selected date from another page and the current date is taken from session. now i want to check one condition that if the selected date is greater than the todays date then open a form else do not open. but the date comparison code is not working. here is my code

Code: [Select]

$user_sel_date=$_REQUEST['myseldate'];
$mycurrentdate=$_SESSION['mycurrdate'];


if ($user_sel_date >= $mycurrentdate) {
echo "inside the if";
}
else
echo "outside the if";


Offline d.shankar

  • Devotee
  • Posts: 532
  • Gender: Male
  • No Terms. One Condition.
    • View Profile
Re: comparing date
« Reply #1 on: September 25, 2007, 03:50:13 AM »
Both dates may be the same , but the may be in different formats.

the former may be dd-mm-yy and the latter may be mm-dd-yy

Have you tried echoing the values ?
There are no rules when you kill for money. Signed in Blood.

Please someone help me solve this topic
http://www.phpfreaks.com/forums/index.php/topic,271648.0.html

Offline localhost1Topic starter

  • Irregular
  • Posts: 37
    • View Profile
Re: comparing date
« Reply #2 on: September 25, 2007, 04:30:48 AM »
yes i have tried this one. both the date is in following format
Code: [Select]
$month=$_REQUEST['mon'];
$year=$_REQUEST['yr'];
$date=date("d");
the date is in the same format.
actually i want to try this code in calender. the above comparison is working in the present month in the calender. but when i click in next month button of the calender then the above comparison is not working.

Offline jitesh

  • Devotee
  • Posts: 807
    • View Profile
Re: comparing date
« Reply #3 on: September 25, 2007, 04:37:19 AM »
What are the date formates ?

Try

$user_sel_date=strtotime($_REQUEST['myseldate']);
$mycurrentdate=strtotime($_SESSION['mycurrdate']);


if ($user_sel_date >= $mycurrentdate) {
echo "inside the if";
}
else
echo "outside the if";

Offline localhost1Topic starter

  • Irregular
  • Posts: 37
    • View Profile
Re: comparing date
« Reply #4 on: September 25, 2007, 05:14:17 AM »
great! thank you very much