thedudeabides Posted November 28, 2010 Share Posted November 28, 2010 I want to do something like this- $days_passed = daysPassed ($last_datetime); //returns (float)number of days (6 hours returns .25 days, 12 hours returns 0.5) $last_datetime = $getCurrentTime(); I will then store $last_datetime in the database for next time. I'm a bit overwhelmed by all the different time and date functions. Does someone have ready made functions that will work here? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted November 28, 2010 Share Posted November 28, 2010 There are a fair few topics around about this, try searching. Here are a few good results. http://www.phpfreaks.com/forums/php-coding-help/date-difference-295142/msg1397605/#msg1397605 http://www.phpfreaks.com/forums/php-coding-help/difference-between-dates-273176/msg1290174/#msg1290174 Shouldn't be hard to tailor it to your needs really. Just a matter of converting dates to UNIX timestamp, subtracting then divide that by 60*60*24 (86400, which is 1 day in seconds). Then round, ceil or floor it. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 28, 2010 Share Posted November 28, 2010 Shouldn't be hard to tailor it to your needs really. Just a matter of converting dates to UNIX timestamp, subtracting then divide that by 60*60*24 (86400, which is 1 day in seconds). Then round, ceil or floor it. So long as you don't mind it being off by an hour for parts of the year. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.