Hector
Hector

Reputation: 682

If statement using date

Right now im using this if statement, but i need to modify it so that it shows include if they signed up AFTER today's date, instead of being equal to

    <?php
    if ($userinfo['signed_up']=="2011-08-29 09:00:00")
      include("launchbuilder_gorilla.php");
    else
      include("launchbuilder.php");
    ?>

Upvotes: 1

Views: 274

Answers (3)

Bobby Jack
Bobby Jack

Reputation: 16018

if ($userinfo['signed_up'] > "2011-08-29 09:00:00")

Should work, according to PHP's in-built type-casting, and that date format. If you need to transfer the current time to that format, use:

if ($userinfo['signed_up'] > date("Y-m-d H:i:s"))

However, as deceze pointed out, that doesn't make a whole lot of sense, so you might want something like:

if ($userinfo['signed_up'] >= date("Y-m-d 00:00:00"))

To check if they signed up at any point 'today'. See the date() function for more info.

Upvotes: 0

Itai Sagi
Itai Sagi

Reputation: 5615

can go the object-based approach: using date_diff()

Upvotes: 0

deceze
deceze

Reputation: 522015

if (strtotime($userinfo['signed_up']) > time())

Back to the Future?

Upvotes: 1

Related Questions