Convert timestamp to readable date/time in PHP
Problem: Convert timestamp to readable date/time in PHP
Solution: This can be achieved with the help of date() function, which is an inbuilt function in PHP can be used to format the timestamp given by time() function. This function returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.
Example 1:
<?php echo date('m/d/Y H:i:s', 1541843467); ?> |
Output:
11/10/2018 09:51:07
Example 2:
<?php echo date('m/d/Y H:i:s', time()); ?> |
Output:
Current Time in formatted form
Reference: http://php.net/manual/en/function.date.php
Recommended Posts:
- How to convert timestamp to time ago in PHP ?
- How to convert Unix timestamp to time in JavaScript?
- HTML | DOM Input Datetime Object
- PHP | Converting string to Date and DateTime
- How do you display JavaScript datetime in 12 hour AM/PM format?
- PHP date() format when inserting into datetime in MySQL
- How to convert a string into number in PHP?
- How to convert string to boolean in PHP?
- How to convert array to SimpleXML in PHP
- Convert given time into words
- How to convert XML file into array in PHP?
- How to convert number to month name in PHP?
- How to convert Set to Array in JavaScript?
- How to convert a JavaScript date to UTC?
- How to convert PHP array to JavaScript or JSON ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



