How to Convert PHP Timestamp to Date Format with example

How to Convert PHP Timestamp to Date Format with example

In this post, i am going to tell you, how to convert PHP Timestamp into more readable date format using date function.

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.
    1. $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.
    1. $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.
    1. $current_timestamp = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")); ?>

Converting the Timestamp into more readable date format
mm/dd/yyyy $date = date("m/d/Y", $current_timestamp);
dd/mm/yyyy $date = date("d/m/Y", $current_timestamp);
With time $date = date("d F Y H:i:s", $current_timestamp);
Without time $date = date("d F Y", $current_timestamp);

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort - akyazı escort - arifiye escort - erenler escort - eve gelen escort - ferizli escort - geyve escort - hendek escort - karapürçek escort - karasu escort - kaynarca escort - kocaali escort - otele gelen escort - pamukova escort - sapanca escort - söğütlü escort - taraklı escort
sapanca escort hendek escort karasu escort escort sakarya sakarya escort bayan adapazarı escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort