calculating time till event
Posted: Mon Apr 04, 2011 7:36 pm
Ok, so I have a mysql db and I know the day and time of an event, what I need to figure out is how to put that into the database, then use a page to tell how much time is left untill the event happens. A bit more detail, let's say there is a class starting on July 4th @ 1pm how would I go about storing that in a database, then figuring out how long until that day and time, and showing that on the page? Sorry I don't have any code as of right now, as I have never messed with dates and times in mysql or php. I know I can do something like $today = time(); $difference = ($target-$today); $days = (int)($difference/3600); to figure out how many hours until $target, but I am not sure how to store the date/time in mysql and then use it in an equation like that to figure out how long till that day/time. Thank you in advance for your help, and a big thank you to the community here, you guys have taught me and helped me a lot.