I’m building a small webservice and the client is an android client.
I must use dates and I want to save it in my database.
The server side is in PHP and the client is in Java. What format is the best to send date to PHP and how can I convert it easily ?
EDIT: When i say format, i’m not talking of the data format. Just the format of the date. Because the data are sent with JSON but the dates are passed as string.
I was thinking about the timestamp but it’s not a good idea since we know its size limit…
Thanks.
@Gp2mv3 –
jmort253 is correct: JSON is an excellent data interchange format. Go for it!
You can use getTimeStamp()” on the PHP side
You can convert a PHP timestamp to a Java long timestamp as follows:
Date d=new Date((long)phpTimeStamp*1000);
PS:
If you use timestamps, you must never assume the client and the server are in any way synchronized with each other.