say i have a date which is
$future_time_ending = "2012-09-21 12:12:22"
How do i work out the number of minutes between the current time and the $future_time_ending?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One method:
strtotimeconverts the date to a Unix timestamp – the number of seconds since the Unix epoch. Subtract the current timestamp and you have the number of seconds between the current time and the future time. Divide by 60 and the result is in minutes.If you don’t know for certain the time you’re comparing is in the future, take the absolute value to get a positive number:
Just to be complete in my answer, there is a more elaborate OO approach available in PHP:
This is especially useful if the input time is from a time zone other than the server’s.