Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Small and probaly easy PHP problem...

  • 21-10-2007 8: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