Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - help converting timestamp string to readable time format

I have a record called Time with the following date string: 20100902040003 in the input file.

I need some php help to convert this to something more readable such as this format: 2010-09-02 04:00:03 and would like to format it as I print out the table data.

like image 549
cjd143SD Avatar asked Sep 03 '10 00:09

cjd143SD


People also ask

What PHP function that formats a timestamp to a more readable date and time?

The PHP strtotime() function is used to convert a human readable date string into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).

How convert date from yyyy mm dd to dd mm yyyy format in PHP?

Change YYYY-MM-DD to DD-MM-YYYY In the below example, we have date 2019-09-15 in YYYY-MM-DD format, and we will convert this to 15-09-2019 in DD-MM-YYYY format. $orgDate = "2019-09-15"; $newDate = date("d-m-Y", strtotime($orgDate)); echo "New date format is: ".

How do you use str to time?

The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.


1 Answers

$timestamp = "20100902040003";
echo date('Y-m-d H:i:s', strtotime($timestamp)); // output: 2010-09-02 04:00:03
like image 139
Naveed Avatar answered Nov 14 '22 22:11

Naveed