How can I retrieve the current date and time within a view in Codeigniter?
Thanks.
EDIT : What I’m trying to do is to subtract the current date/time from posted date/time and display it as “posted x days ago”
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I use this helper for Codeigniter (you can see the original here: codeigniter forums)
I use this code:
I’m not sure if you’d always want it to say “days”, this code does whatever is least (like ’49 seconds ago’, or ’17 minutes ago’, or ‘6 hours ago’, or ’10 days ago’, or weeks or months (or even years). If what you’re looking for is only the days, it’d be easy enough to alter this script.