Code Snippets

How to Convert Date to Time ago WordPress

Maan
Feb 7, 2016
1 min read
62 words
How to Convert a date to time ago

This Snippet is supposed to add in single.php, index.php or any other template within the loop. Don’t you think it would be finest thing to display on post where you can show post like “1 hour ago, 2 hour ago, 1 day ago” etc.

echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';

via Codex , Thumbnail image via inspirationde

Maan

Author

Maan is a Lead Frontend Engineer and Creative Director with 10+ years of industry experience blending UI/UX design with React-based development. A multifaceted practitioner, he has spent a decade turning abstract inspiration into deployed, scalable reality. Maan’s expertise lies in high-fidelity prototyping and component architecture, which he shares through insightful technical writing with the next generation of developers. His unique approach ensures that pixels not only meet passion but also rigorous performance standards.

View all posts

Continue reading

You might also like

Leave a Reply

Your email address will not be published. Required fields are marked *

Menu