PHP Timestamp to Date Readable Format With ExamplePHP Timestamp to Date Readable Format With Example

Convert PHP Timestamp to Date readable format, In this tutorial, we do a complete discussion about all the conversions with help of the example. Here is the list of line items which we discuss further,

  • PHP timestamp to date
  • PHP UNIX timestamp to date time
  • UNIX time live
  • PHP convert date to UNIX timestamp
  • Convert PHP timestamp to date with specific timezone
PHP Timestamp to Date Readable Format With Example
PHP Timestamp to Date Readable Format With Example

Convert PHP Timestamp to Date with Example

With help of PHP date function date('m/d/Y') we can convert timestamp to human readable date format.

Output:

04/17/2021

Convert PHP UNIX Timestamp to Date Time Both With Example

We use the same as above PHP date function with the help additional time parameter date('m/d/Y H:i:s').

Output:

04/17/2021 16:30:41

Convert UNIX Timestamp to Live Time

To get live time we PHP time function time() which is gives current time in UNIX timestamp format.

Output:

Current date and time

PHP Convert Date to UNIX Timestamp With Example

Using strtotime() function we can convert human readable date to UNIX timestamp.

Output:

1618531200

Convert PHP Timestamp to Date With Specific Timezone

Also Check Live on https://codingtasks.net/php-online-editor/

Output:

Current date and time of specified zone
17-04-2021 22:04:01

Code Highlights:

  • First, we set the origin time zone $time_zone_from then define that zone which we want to get the time $time_zone_to.
  • Then we use the PHP DateTime object to set the user-defined timezone.
  • Now we convert it and print the date-time with specified zone and with the specified format.

This tutorial has complete guide about PHP UNIX timestamp and PHP date conversion opertions.

You can also check more on PHP timestamp and date https://www.php.net/manual/en/datetime.gettimestamp.php

Bonus Points on PHP Date Function

  • mm/dd/yyyy: date("m/d/Y", $current_timestamp);
  • dd/mm/yyyy date("d/m/Y", $current_timestamp);
  • With time date("d F Y H:i:s", $current_timestamp);
  • Without time date("d F Y", $current_timestamp);

Also Check:

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

3 thoughts on “PHP Timestamp to Date Readable Format With Example”

Leave a Reply

Your email address will not be published. Required fields are marked *