0

I have done this in Java:

Calendar lCDateTime = Calendar.getInstance();
date = lCDateTime.getTimeInMillis();

I have done this in PHP:

  $date = date(U);      

In Java, it is working. In PHP it doesn't.

In Java I get: 1358789604926
In PHP I get: 1358790190 (a smaller number)

Can anyone explain the difference between the two results?

2 Answers 2

8

The timestamp generated by Java is in miliseconds, while the timestamp generated by PHP is in seconds. So in order to compare the two, you just need to "drop" the last three digits of the Java timestamp with division by 1000.

Sign up to request clarification or add additional context in comments.

3 Comments

Perfect. I actually NEED it in miliseconds. So just times the PHP one by 1000 then.
@KickingLettuce, wouldn't be 100% accurate, but yes.
To get time in milliseconds in PHP, use round(microtime(true)*1000)
0

The java result is the number of milliseconds since the start of the unix epoch in 01.01.1970, the second are the seconds.

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.