Question: I got an application form on my page that close at a certain date. However, it's closing exactly as soon as the time hits that certain date (i.e. 13th of April), but I would like it, for example, to close at 13th of April at 14:00. I've created a dropdown in my WordPress (add\_time) with outputs the string of 14:00. How can I add that to the date so $daysleft includes those added hours as well?

Something like? 

```
$addedTime = get_field('add_time');
$addedTime = strtotime ($addedTime);
$daysleft = floor($datediff/(60*60*24)+$addedtime)) +1 <--- (not sure where to one is for)

```

Below if the complete code as it is currently

```
<?php
    $now = time();
    $dueDate = get_field('due_date');
    $addedTime = get_field('add_time');
    $dueDate = strtotime($dueDate);
    $datediff = $dueDate - $now;
    $daysLeft = floor($datediff/(60*60*24))+1;
    $daysLeft = intval($daysLeft);
 ?>
 <?php 
    if($daysLeft == 0) {
        echo 'Last day';
    } elseif($daysLeft < 0) {
        echo 'Deadline passed';
    } elseif($daysLeft == 1) {
        echo $daysLeft.' days left';
    } else {
        echo $daysLeft.' days left';
    }
 ?>

```

Answer: 
I first of all recommend to use [Carbon](http://carbon.nesbot.com/docs/) But you can also use a standard [DateTime](https://secure.php.net/manual/en/class.datetime.php) object.

**DateTime**

```
$date = new DateTime('20-04-2017');
$date->add(new DateInterval('P1D'));
echo $date->format('d-m-Y');

```

**Carbon**

```
use Carbon\Carbon;

$date = new Carbon::createFromFormat('d-m-Y','20-04-2017');
$nextDay = $date->addDay();
echo $nextDay->format('d-M-Y');

```

Now for your application I'd use Carbon in the following way:

```
$enddate = Carbon::createFromFormat('d-m-Y H:i:s','14-04-2017 14:00:00');
if(Carbon::now()->gte($enddate)) {
   //Application ended code
}
else {
   // application active code
}

```

If you wish to use DateTime you can do this:

```
$enddate = new DateTime('2017-04-13 13:00:00');
$now = new DateTime('now');

$diff = $enddate->getTimestamp() - $now->getTimestamp();

if($diff >= 0) {
    echo 'active';
}
else {
    echo 'inactive';
}

```
For operations with date and time better to use [DateTime class](http://php.net/manual/en/class.datetime.php)

To receive time in 1 hour you can use following code:

```
$time = new DateTime();
$time->modify("+1 hour");
echo $time->format("Y-m-d H:i:s");

```

With that class you also can compare to dates