You are invited to Log in or Register a free Frihost Account!

# Future or Past

DanielXP
I need a script that can tell me if the date is in the future or in the past.

My date varibles are as follows.

\$day = day (eg. 11)
\$month = month (eg. 4)
\$year = year (eg. 2008)

If so then the varible

\$status Would then equal past

Or

\$day = day (eg. 1)
\$month = month (eg. 10)
\$year = year (eg. 20190)

\$status Would then equal future

Daniel
rvec
 Code: \$day = date(j); \$month = date(n); \$year = date(o);

I think you can get it from there.
DanielXP
i have tryed that i had like loads of if's for like if the month is bigger but the year is less or month is less and so is the year and as well as loads of them you have the day
sonam
Try this:
 Code: \$year) {    \$msg = "You are in the future!"; } elseif (\$year2 < \$year) {    \$msg = "You are in the past!"; } else {    if(\$month2 > \$month) {       \$msg = "You are in the future!";    } elseif (\$month2 < \$month) {       \$msg = "You are in the past!";    } else {       if(\$day2 > \$day) {          \$msg = "You are in the future!";       } elseif (\$day2 < \$day) {          \$msg = "You are in the past!";       } else {          \$msg = "You are in the NOW!";       }    } } echo \$msg; ?>

Sonam
DanielXP

I found a site on google and edited it so i could get it to work for me.

 Code: function dateworkout(\$date) { \$dateN = explode("/", \$date); \$dateString = \$dateN[2] . "-" . \$dateN[1] . "-" . \$dateN[0]; if(strtotime(\$dateString) > time()) { \$status = "future"; }else if(date("Y-n-j", time()) == \$dateString) { \$status = "now"; }else if(strtotime(\$dateString) < time()) { \$status = "past"; } return \$status; }

So
 Code:

would echo "past"