Reputation: 3022
I had this weird problem a little while ago and haven't been able to find a solution yet. In my application, I keep some information about the activity of the user on my server. I also keep the date of the activity using getdate() function of PHP. When queried, I send this information back to the phone and try to represent the date in a more human-readable format.
For example,
//This is the part that runs on the server
$timeOfAct = getdate();
//$timeOfAct = 1339637005. I guess this is the date in milliseconds
//INSERT $timeOfAct to database
I send this information back to the application using JSON.
//st="1339637005"
SimpleDateFormat ft = new SimpleDateFormat("MM/dd/yyyy");
Date resultdate = new Date(Long.parseLong(st));
st=ft.format(resultdate);
st always becomes 01/16/1970.
As far as I understand, date 0 for JAVA is not equal to 0 for PHP.
So, do you have any suggestions for me to achieve a successful conversion?
UPDATE: I forgot to mention that I was using the 0th element of the array returned by getdate() which is equal to what is returned by time() function
//E.g. INSERT $timeOfAct[0]
Upvotes: 0
Views: 164