我需要将两种不同格式的两次加在一起:
我需要将两者加在一起以获得总数,例如:12:30 + 0.5 = 14:00。
我目前陷入困境并且错过了一些简单的事情,有人能指点我吗?
代码:
// 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);
答案 0 :(得分:3)
$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)));