Codeigniter and jquery-timeago showing 6hours ago

I’m trying to setup a commenting system in Codeigniter with jquery-timeago plugin which seems to be fine on my localhost but on the server, it keeps showing 6hours ago for new comments.

Any thought?


Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

As @kcristella said, you will need to make sure that your local timezone and your server’s timezone match because jquery-timeago runs on the client and thus uses the local timezone, but processes the date that the server returned, which matches the server’s timezone.

However, this would not work for visitors with different timezones, so you will want to calculate the x time ago part on the server itself and not in the browser. Another option would be converting the time to the visitor’s timezone and then jquery-timeago will work correctly.