Page 1 of 1

Date application (solved)

Posted: Mon Jun 28, 2010 10:05 am
by dimxasnewfrozen
I'm working on a simple date application that generates a table (kind of like a graph but not using graph libraries).

Code: Select all

$start =  str_replace(".000000", "", $results['START_DATE'][0]);
// $start =  	 28-JUN-10 09.37.25 AM 

$end   =  str_replace(".000000", "", $results['END_DATE'][0]);
// $end =  	 28-JUN-10 10.00.15 AM 

// $DUR = the difference, in this case 23 minutes. 
$columns  = 10;
$rows 	= 5;

$interval   = $DUR / 10;
// $interval = 2.3 (minutes)

$start_time = explode(" ", $start);
// $start_time[1] = 09.37.25 

$interval_value = 0;
$starting_time = $start_time[1];

for ($i = 0; $i < $columns; $i++){
	$interval_value = $interval_value + $interval;
        $new_time     = $starting_time + $interval_value; 
        // I want to display the start_time + interval_value;
       // Logically: Loop1  9.37.25 + 2.3 minutes
       //  Logically: Loop2  ~9.39.25 + 2.3 minutes
       //  Logically: Loop3  ~9.43.25 + 2.3 minutes
      //  Logically: Loop10 ~ close to the end time
}


I'm not sure how to add 2.3 minutes (or whatever the interval would be) to a time in that format.

Re: Date application

Posted: Mon Jun 28, 2010 10:25 am
by dimxasnewfrozen
Actually, adding minutes to a time isn't the best idea.

I converted it to seconds and will just add the seconds to the start time.

Code: Select all

$DUR = '1370';
//or 2.3 minutes.

// How to add $DUR to 09:37:25 ?


Woot I got it:
$DUR + strtotime($start_date);