Time Ago Function is a function that is commonly used to display time in human understandable format, as you have seen many times on social networks, whenever you post any status on your Facebook, Twitter or any other network, it says posted few seconds ago, 1 min ago, 1 hour age, etc. This is actually done by subtracting the post published time from the current time.
For this purpose we need to store a date in database, date should be in MySQL standard date and time format (“Y-m-d H:i:s”).
This is my first post on my AllPHPTricks blog so i would like to start with the beginning so even if you are not aware how to run PHP on your local machine you can do it just following this tutorial, let me introduce first XAMPP.
What is XAMPP?
XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P) and Perl (P). XAMPP is very simple and lightweight Apache distribution, i prefer to use it because you can install it any platform Windows, Linux or Mac.
XAMPP has four main components:
Apache is a web server that processes PHP files and convert them into simple HTML and send it to the web browser of a user. Apache is the most famous web server today, more than 50% websites using it.
Almost all the websites that are dynamic needs to store data for that purpose we uses a database. MySQL is an open source and the world’s most famous database management system.