Jump to content

arrayGen

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Posts posted by arrayGen

  1. what layer of the application would you tackle this problem in ? only an idiot would do it like that

     

    You did post this in the PHP forum, right? So it is only logical that you were looking for a PHP solution. If you wanted a database or other type of solution you should post in the appropriate forum.

     

    not too sharp today are we Jaldinder Gee

  2. Would be stupid to write anything more than 1 standalone file script as proceedural, you would be making a car out of twigs and leaves.

     

     

    Creat eyour objects

     

    Engine()

     

    Lancher()

     

    GuardDog()

     

    Memory()

     

    Html()

     

    Controlers()

     

    Modles()

     

    Interupts()

     

     

    and make them all work together sohow() however you feel, writ ethem however you feel, only you can judge how good its going to be or what style or technique to use.

    Machine::add(Engine(),
    Lancher(),
    GuardDog(),
    Memory(),
    Html(),
    Controlers(),
    Modles(),
    Interupts()
    )->start();
    

     

     

  3. Why do you see the need to resort to name calling?

     

    What was not clear in the previous posts was that the end time may - intentionally -  be less than the start time. If that is the case, then I would assume that the end time is for the next day.

     

    So the solution is simple. If the end time is before the start time, then increment the end date to +1 days.

    $start_time = "11:00:00";
    $end_time = "00:00:00";
    $date = "2011-01-01";
    
    $start_timestamp = strtotime("{$date} {$start_time}");
    $end_timestamp = strtotime("{$date} {$end_time}");
    //Check if end time is before start time
    if($end_timestamp < $start_timestamp)
    {
        //Adjust end date to next day
        $end_timestamp = strtotime("{$date} {$end_time} +1 days");
    }
    
    echo "Start date/time: " . date('m-d-Y H:i:s', $start_timestamp);
    echo "<br />End date/time: " . date('m-d-Y H:i:s', $end_timestamp);
    
    //Output
    //Start date/time: 01-01-2011 11:00:00
    //End date/time: 01-02-2011 01:00:00
    

     

    your still unsure, mr self proclaimed guru, who invented guru ? and mogul ?

     

    what layer of the application would you tackle this problem in ? only an idiot would do it like that

  4. Why do you see the need to resort to name calling?

     

    What was not clear in the previous posts was that the end time may - intentionally -  be less than the start time. If that is the case, then I would assume that the end time is for the next day.

     

    So the solution is simple. If the end time is before the start time, then increment the end date to +1 days.

    $start_time = "11:00:00";
    $end_time = "00:00:00";
    $date = "2011-01-01";
    
    $start_timestamp = strtotime("{$date} {$start_time}");
    $end_timestamp = strtotime("{$date} {$end_time}");
    //Check if end time is before start time
    if($end_timestamp < $start_timestamp)
    {
        //Adjust end date to next day
        $end_timestamp = strtotime("{$date} {$end_time} +1 days");
    }
    
    echo "Start date/time: " . date('m-d-Y H:i:s', $start_timestamp);
    echo "<br />End date/time: " . date('m-d-Y H:i:s', $end_timestamp);
    
    //Output
    //Start date/time: 01-01-2011 11:00:00
    //End date/time: 01-02-2011 01:00:00
    

     

    your still unsure, mr self proclaimed guru, who invented guru ? and mogul ?

  5. the super twats from the super companies all use

     

    start: 11::00:00

    end: 00:00:00

    date: 2011-01-01

     

    you can see the apparent failure here. ??? can you ?

     

    I don't think you should be throwing derogatory names around like that. Because as arrayGen just alluded to, it seems YOU are the only one that doesn't see the obvious solution:

     

    Combine the date with each time - individually - to come up with two timestamps! Although your example is in error since the end time is before the start time. 00:00:00 is the beginning of a day not the end of a day. So, in reality your two timestamps should be

     

    Start timestamp: 2011-01-01 11:00:00

    End timestamp: 2011-02-01 00:00:00

     

    yes Sherlock, but what im trying to say is, the times are stored as

     

    start: 11::00:00

    end: 00:00:00

    date: 2011-01-01

     

    but how would you manipulate this to correct it ?

     

    strtotime(date("Y-m-d H:i:s", "{end} {date}")) - strtotime(date("Y-m-d H:i:s", "{start} {date}"))
    

     

    will cause a minus time , this is true but how do we rectify this what would be the best angle of attack.

     

     

  6. It would probably be helpful if you posted what data you do have and what result you are trying to accomplish. It sounds like a date and two times per row? What format is the date and what format is the time?

     

     

    the super twats from the super companies all use

     

    start: 11::00:00

    end: 00:00:00

    date: 2011-01-01

     

    you can see the apparent failure here. ??? can you ?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.