Results 1 to 2 of 2

Thread: Adding hours to datetime

  1. #1
    Join Date
    Mar 2012

    Adding hours to datetime

    I am working on a water mgmnt sys for a company and need to add hours to a datetime value in oder to produce a projected datetime value. I dont know if this can be done but any help would be great.

    //MAX_TOP = 96 inches
    //BARRELS_PER_INCH = 1.67 bbl or barrels per hour
    $last_bottom = $row['bottom'];//lets say 33 inches
    $last_pulled = $row['last_pulled'];//2012-07-31 09:39:14 
    $bbl = $row['bbl_per_hour'];//12.70 barrels per hout
    $projected_fill = MAX_TOP - $last_bottom;
    $projected_barrels = $projected_fill * BARRELS_PER_INCH;
    $time_to_fill = $projected_barrels/$bbl;
    the result here $time_to_fill gives about 8.2 hours now I need to add this to $last_pulled to get my projected datetime.


  2. #2
    Join Date
    Mar 2012
    Well I found my answer
    $exploded_time = explode('.', $time_to_fill);
    $hours = $exploded_time[0];
    $frac_hours = '.'.$exploded_time[1];
    $minutes = floor($frac_hours*60);
    $projected = strtotime($last_pulled." +".$hours." hours"." +".$minutes." minutes");
    echo date("F j, Y H:i:s",$projected);
    in case you were wondering

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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