Reputation: 1316
I've checked the PHP manuals, and also googled prior to asking this question, but am still confused about how to do this correctly - How can I check whether my datetime variable's time part is greater than a given time?
Suppose I have a variable $time
like the following:
$mdata['entry_date_time'] = $this->input->post('entry_date_time');
$time = $mdata['entry_date_time']->format('H:i:s');
What I want to do is something like this:
if($time > 12:00:00)
{
//do something
}
My questions, based on the second code snippet, are:
Upvotes: 0
Views: 117
Reputation: 41875
Depending on the format of the input, you could use datetime in this case:
$date_input = $this->input->post('entry_date_time');
$date = new DateTime($date_input);
if($date->format('H') > 12) {
// do what you have to do
}
If you have a format that cannot be used directly on the constructor, you might need to use createFromFormat
:
To answer fully:
->
an arrow operator doesn't make sense since its not an object.Upvotes: 2