0

From an external website I receive, amongst other data, a date/time stamp like this 1346729259806 or 1346734102948 I have been trying to see what the best way to convert this into a formatted date/time readable for later use.

I found out that the timestamp is Epoch format in miliseconds. Is there a regular way to convert this?

Many thanks in advance

1

2 Answers 2

6

date() function takes the second parameter as the timestamp.

echo date('Y-m-d H:i:s', 1346729259806/1000);
Sign up to request clarification or add additional context in comments.

1 Comment

i was sending from Android to php and it wasnt converting. Then i saw your "/1000" xD
0

You can convert the timestamp to date in mysql by using DATE and FROM_UNIXTIME function. The command given bellow,

FROM_UNIXTIME
SELECT create FROM phpkit ;

The output created:

1216053466

Then:

SELECT DATE( FROM_UNIXTIME( `created` ) ) AS pDate FROM phpkit

Output:

2008-07-14

I found the source from the following link.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.