onedumbcoder Posted July 22, 2009 Share Posted July 22, 2009 Is there a simple way to determine how many years, months, weeks, days, hours, ago using a time stamp? Quote Link to comment https://forums.phpfreaks.com/topic/166972-how-many-years-months-weeks-days-hours-ago-from-datetime/ Share on other sites More sharing options...
celsoendo Posted July 23, 2009 Share Posted July 23, 2009 DATEDIFF(date1, date2); http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html It returns on days, but you can apply some divisions to get all the info you want. Quote Link to comment https://forums.phpfreaks.com/topic/166972-how-many-years-months-weeks-days-hours-ago-from-datetime/#findComment-880914 Share on other sites More sharing options...
Third_Degree Posted July 23, 2009 Share Posted July 23, 2009 php.net/time Read the user comments Quote Link to comment https://forums.phpfreaks.com/topic/166972-how-many-years-months-weeks-days-hours-ago-from-datetime/#findComment-880915 Share on other sites More sharing options...
haku Posted July 23, 2009 Share Posted July 23, 2009 It returns on days, but you can apply some divisions to get all the info you want. Division doesn't work so well - every month has different numbers of days, and even years have leap years. Quote Link to comment https://forums.phpfreaks.com/topic/166972-how-many-years-months-weeks-days-hours-ago-from-datetime/#findComment-880926 Share on other sites More sharing options...
Philip Posted July 23, 2009 Share Posted July 23, 2009 DATEDIFF(date1, date2); http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html It returns on days, but you can apply some divisions to get all the info you want. More specifically, using TIMEDIFF would give back not only days, but hours/minutes/seconds as well. Quote Link to comment https://forums.phpfreaks.com/topic/166972-how-many-years-months-weeks-days-hours-ago-from-datetime/#findComment-880930 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.