Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Exclamation PHP Time Thingy..

    Hey,

    A little tricky question (or simple )
    Ive got a script that I am running on a 5 minute cron & want it only to run after 07:30 and to stop running after 20:00.

    How would I make PHP do this?

    I thought of something like..

    PHP Code:
    if(date("H:i") >= date("H:i""07:30") && date("H:i") <= date("H:i""20:00")){
        echo 
    "The time is after 07:30 and before 20:00";
        exit();
    }else{
        echo 
    "The time is before 07:30 or after 20:00";
        exit();

    Doesnt work though :S someone help? +REP !

    Lew.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    This should hopefully work

    PHP Code:
    <?php

    date_default_timezone_set
    ("Europe/London");

    if ((int)
    date("Hi") >= 0730 && (int)date("Hi") <= 2000){ 
        echo 
    "The time is after 07:30 and before 20:00"
        exit(); 
    }else{ 
        echo 
    "The time is before 07:30 or after 20:00"
        exit(); 
    }  

    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •