How To Convert Timestamp To Date in PHP
Hello everyone in this tutorial I will explain How TO Convert Timestamp To Date in PHP, before starting a convert from timestamp to a date, we should know about what is a timestamp and why we used a timestamp in any web application for managing the detail.
so whenever you have any timestamp then you can easily convert from timestamp to human readable format using PHP in-built function date(), date function always converts any timestamp to a readable format.
How TO Convert Timestamp To Date in PHP
$convert = time();
echo date('d - M - y',$convert);
26 - January - 18
Explain time() function return the current local time in an integer like 192928837 in seconds, and its non-human readable format, so to make it human readable format we need to convert it like “26 – Jan – 2018“. We will use date() function to convert to exact format in which we want.
d: day of month
M: capital M return month name in three characters only like( Jan, Feb, Mar) if you want to return full name of the month you may use a capital “M“.
y: small y return the year in two digits like 18, if you want to return full name of the year like 2018, use Capital “M”.