I’ve just released a new PHP library for simplifying Ajax requests in WordPress plugins and themes. It’s called WP Ajax Helper, and you can find it on GitHub and Packagist.
Continue reading
PHP
Better Human-friendly Time Ago PHP Function
Last month I posted about a Human-friendly Time Ago PHP Function. Well, I’ve come across another way of doing it. This method has less code duplication, but is harder to understand at first glance. I prefer this method though, as it seems a bit more elegant than the other method. I’ve refined the code from the Stack Overflow post, and here’s what I have now.
Continue reading
Human-friendly Time Ago PHP Function
Say you want to get the amount which has elapsed in a human-friendly format. Something like “27 minutes ago” or “3 days ago.” If you’re using WordPress, there is a handy function called human_time_diff() which does just that. But if you’re not using WordPress, here is a PHP function which will do the same.
Continue reading