Reputation: 53
I need some assistance.
The code uses a date()
function to acquire the report date, while the availability times are manually entered by users. The availability times are then compared to a static time in order to show whether the process was complete on time.
This process works perfectly if all processes run on the same day; however inaccurate reporting occurs when the process completes before midnight of the previous day. This is where I need some assistance.
I need to take the time string, which is set as H:i
format, and merge it with the date string, which is set as yyyy/mm/dd
. Once this is performed, I can compare it to the report date stamp to get proper reporting.
Upvotes: 3
Views: 2916
Reputation: 913
Something like this might point you in the right direction:
<?php
$date = "2013/01/04";
$time = "16:58"; // I'm assuming you meant H:i format (not capital I as in your question).
$timestamp = strtotime($date." ".$time);
echo $timestamp; // 1357318680
?>
Upvotes: 2
Reputation: 13534
Concat the two strings respectively, date and time then insert the result string into strtotime()
$date = '2012/06/15';
$time = ' 10:33';
echo strtotime($date.$time)
Upvotes: 4
Reputation: 157839
concatenation operator in PHP is a dot, "."
and you can always concatenate whatever date with whatever time
$date = "2012/01/04";
$time = "22:12";
$datetime = $date." ".$time;
then you can compare the latter variable with whatever datetime of the same format
Upvotes: 3