kevin_newbie Posted January 26, 2010 Share Posted January 26, 2010 Hello, I have noticed that sites usually format dates of entries like: "Submitted 1 hour ago. or Submitted 1 day 2 hours ago. " What is the logic of doing something like this? Right now I have the date already inserted in the db along with the entries and just want to be able to format with days instead of the traditional Jan. 25th 2009 @ 4:25pm. Thanks, kevin_newbie. Quote Link to comment https://forums.phpfreaks.com/topic/189800-day-format-with-datetime/ Share on other sites More sharing options...
premiso Posted January 26, 2010 Share Posted January 26, 2010 It is the difference between the date in the DB and NOW. http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_datediff Quote Link to comment https://forums.phpfreaks.com/topic/189800-day-format-with-datetime/#findComment-1001615 Share on other sites More sharing options...
kevin_newbie Posted January 26, 2010 Author Share Posted January 26, 2010 Okay so using this function is echoing out one integer which is the day correct? DateDiff(startdate(now()), enddate(datetime from db)) Quote Link to comment https://forums.phpfreaks.com/topic/189800-day-format-with-datetime/#findComment-1001628 Share on other sites More sharing options...
fenway Posted January 28, 2010 Share Posted January 28, 2010 I don't understand your question. Quote Link to comment https://forums.phpfreaks.com/topic/189800-day-format-with-datetime/#findComment-1002786 Share on other sites More sharing options...
premiso Posted January 28, 2010 Share Posted January 28, 2010 You may have a look at this script, as it may better suit your needs / be easier for you to understand: http://snippets.dzone.com/posts/show/3044 Quote Link to comment https://forums.phpfreaks.com/topic/189800-day-format-with-datetime/#findComment-1003106 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.