How much time left and how much time past between times

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!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

How much time left and how much time past between times

Post by lovelf »

Code: Select all

<?php
$date = new DateTime();
$date=$date->format('Y-m-d H:i:s');
echo $date;
outputs: 2012-03-07 13:05:11
?>
I would like to check against a same format of date for time left between one date an another and time past between one date an another, a simple function that returns the time left between a data and another and that returns the time past between one date an another, it can be in hours, days, or minutes. For example: two days past or two days left, or two hours past or two hours left, or 10 minutes past or 10 minutes left.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How much time left and how much time past between times

Post by Celauran »

Post Reply