views:

295

answers:

3

Hello,

I have a java file that write records to the DB and time stamps

I have another php file that reads that records..

unfortunately After converting the time stamp to dates I got a wrong dates ??

what is the problem !!!

A: 

PHP uses the UNIX epoch, I suspect Java uses a different epoch.

EDIT: I was way off, turns out PHP uses seconds, java uses miliseconds. So multiply by 1000 or divide by 1000 depending on which way you're converting.

gargantaun
+7  A: 

Java uses a timestamp which is milliseconds from the epoch. PHP uses the standard unix timestamp which is seconds from the epoch.

I believe both use the same epoch of Jan. 1, 1970 00:00:00 UTC

tschaible
A: 

I think the problem is you're retrieving a DATETIME or TIMESTAMP column or such that has been stored and screwing up the conversion. Try this:

$phpdate = strtotime( $dateFromDb );
echo date("F j, Y, g:i a", $phpdate);
karim79