In this post, i am going to tell you, how to convert PHP Timestamp into more readable date format using
In PHP, you can easily convert date formats according to need because PHP has date function with several date formats.
This is the best way to keep track of dates and times using PHP Timestamp.
The timestamp is the value of time calculated in seconds, since UNIX Epoch, January 1, 1970 and it is also known as UNIX timestamp.Getting Timestamp in PHP
There are so many ways to get current timestamp value in PHP.
time() :This is one of them which is widely used to get current timestamp value in PHP. You don't need to pass any argument in this function to get timestamp value.
- $current_timestamp = time(); ?>
strtotime() :To get UNIX timestamp value, we mainly used this function. To denote date values There are various supported strings to be passed as an argument in this function. For example: "next Monday","last Sunday","+5 hours","+1 week","now" and etc.
- $current_timestamp = strtotime("now"); ?>
Using now, we will get current timestamp value.
mktime() :This method is also used for same getting UNIX timestamp but there are set of parameters, you need to pass in this method such as hour, minute, second, month, day, year.
- $current_timestamp = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")); ?>