Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Small and probaly easy PHP problem...

  • 21-10-2007 09:00PM
    #1
    Closed Accounts Posts: 388 ✭✭


    Hey there,

    The following code;

    [PHP]$d = date("29/10/07");

    if ($d > date("23/10/07") && $d < date("26/12/07")) {echo 'WORKS!');} [/PHP]

    Will not work, any ideas?


Comments

  • Closed Accounts Posts: 20,759 ✭✭✭✭dlofnep


    Hey there,

    The following code;

    [PHP]$d = date("29/10/07");

    if ($d > date("23/10/07") && $d < date("26/12/07")) {echo 'WORKS!');} [/PHP]

    Will not work, any ideas?

    Not a PHP guy, but you forgot a bracket before "WORKS".

    [PHP]
    $d = date("29/10/07");

    if ($d > date("23/10/07") && $d < date("26/12/07"))
    {
    echo ('WORKS!');
    }
    [/PHP]


  • Closed Accounts Posts: 388 ✭✭Troublesome


    still wont work.


  • Closed Accounts Posts: 20,759 ✭✭✭✭dlofnep


    do an else statement to make sure the code is running and print an error. then you know it's a logic problem.. to me, date looks like a string - but i'm not sure if there is variable types in php? and if it's a string, $d can't be checked to see if it's "higher" or "lower" than another string. but i don't know the return type of date. if it's an integer, then it should run.. check for that and get back to me.


  • Closed Accounts Posts: 313 ✭✭Dalfiatach


    The host server could be set to US date formats. Always use ISO (YYYY-MM-DD) format for dates to avoid annoying Euro/US date conversion problems.

    The PHP date() and mktime() functions (and related friends) are extremely powerful and very nifty indeed if used properly. Used badly, all hell will break loose :p


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    try this way:
    [php]


    if ( strtotime(date("2007-10-29")) > strtotime(date("2007-10-23")) && strtotime(date("2007-10-29")) < strtotime(date("2007-12-26")) ) {
    echo ('WORKS!');
    }
    [/php]


  • Advertisement
Advertisement