PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$datetime1 = new DateTime('2009-10-11 14:52:05');
$datetime2 = new DateTime('2009-10-11 14:53:05');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days');
This works for days with negatives, but not minutes.
Don't see how to make it work for minutes (it will usually be just minutes - if beyond that, I'll prob just block it out.
if ($row->calltime == "ASAP")
{
$minutes_to_add = 5;
}
if ($row->calltime == "30 minutes")
{
$minutes_to_add = 30;
}
if ($row->calltime == "1 hour")
{
$minutes_to_add = 60;
}
$time = new DateTime($row->dateraised);
$time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
$stamp = $time->format('Y-m-d H:i:s');
echo date('D, d M Y H:i:s', strtotime($stamp));
echo "<br/>";
// only show time left if not closed
if ($row->dateclosed == NULL)
{
// timenow
$datetime1 = new DateTime($todaydate);
// call due
$datetime2 = new DateTime($stamp);
$interval = $datetime1->diff($datetime2);
$timeleft = $interval->format('%r%i');
// assigned to variable to query
echo "<br/>$todaydate<br/>$stamp<br/>$timeleft<br/><br/>";
The above is echoing:
[text]2014-07-10 11:30:19
2014-07-10 10:20:48
-9[/text]
It cannot be -9, as it's over an hour ago?!?!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.