Reputation: 1089
I have two times in two different formats that I need to add together:
I need to add both together to get the total, Ex: 12:30 + 0.5 = 14:00.
I am stuck currently and am missing something simple, could anyone give me a pointer?
Code:
// Get Post Time
$post_date = strtotime(get_the_date('G:i'));
// Get User Submitted Number
$post_duration = strtotime($course_hours);
// Add Together
$output = $post_date + $post_duration;
// Output
echo 'Start Time: '.get_the_date('G:i') .' - ';
// Fail Here
echo 'End Time: '. date('G:i', $output);
Upvotes: 0
Views: 92
Reputation: 2741
$add = 0.5 * 60 ; // convert posted hours to minutes
$post_time = "12:30";
echo $post_date = date('G:i',strtotime("+ $add minutes" , strtotime($post_time)));
Upvotes: 3