I have a form that I would like a user to enter "X" amount of minutes. The form will post to another php page for output to the user. What I would like to do is use the value of "X" minutes - (minus) the current server time to determin what the date and time would have been "X" minutes ago. In other words...If I said that something occured 10 minutes ago on the form, then I want PHP to figure out what the Date & Time was 10 minutes ago, and echo it to the user. I have searched everywhere, but I cannot find the exact code that I would need to achieve this...any help would be much appreciated!
That worked perfectly...thanks for your time!!! There is just one more thing that I think I need regarding time. I am also wanting to echo the amount of "x" minutes to the user. But if x is greater than 1 hour, I would like for PHP to echo x hour(s), and x minutes(s). Instead of displaying 144 minutes, I would like it to display 2 hours, 24 minutes. Thanks again...
echo "Duration: " . floor($x / 60) . " hours " . ($x % 60) . " minutes"; I'm sure you'll be able to work out the if statement yourself
Works great.. This is my if statement: if ( $down_minutes < 60 ) { echo $down_minutes . " minutes<br /><br />"; } elseif ( $down_minutes == 60 ) { echo "" . floor($down_minutes / 60) . " hour <br /><br />"; } else { echo "" . floor($down_minutes / 60) . " hour(s) " . ($down_minutes % 60) . " minute(s)<br /><br />"; } I am sure that there has to be a better way for me to display "x hour" for every 60 minutes (see 3rd line)...but the only way I would know would be to do a bunch of if elseif statements for 60 minute increments?? Thanks again!!!
Maybe this? Checks if the minutes / 60 is a whole number, if it is then it's obviously an "o'clock". Seems to work when I tested... if ( $down_minutes < 60 ) { echo $down_minutes . " minutes<br /><br />"; } elseif ( is_int($down_minutes / 60) ) { echo floor($down_minutes / 60) . " hour(s) <br /><br />"; } else { echo floor($down_minutes / 60) . " hour(s) " . ($down_minutes % 60) . " minute(s)<br /><br />"; } PHP: