473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP timestamp comparison with java.util.Date.getTime() timestamp

I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:

PHP time (using microtime()): 0.79479900 1079196997
Java time: 1079165215886
The Java time is returned to the PHP class method as mixed but could
be converted to float I would think, but how would I ensure that they
would be compared correctly when I do this:

[PHP]
if (time() - $lastMsgTime >= 86400) { // DO STUFF }
[/PHP]

Thanx
Phil
Jul 17 '05 #1
2 11626
[ "Followup-To:" set to comp.lang.php ]
Phil Powell wrote:
I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:

> PHP time (using microtime()): 0.79479900 1079196997

> Java time: 1079165215886

Good! they look very similar
The Java time is returned to the PHP class method as mixed but could
be converted to float I would think, but how would I ensure that they
would be compared correctly when I do this:
I don't know Java, much less how to integrate it with PHP so I'm just
assuming you get a string variable available in PHP with the Java time:

<?php
$java_time = '1079165215886';
$php_time = '0.79479900 1079196997';

$java_time /= 1000;

$php_time = explode(' ', $php_time);
$php_time = $php_time[1];
## it's a pity you can't do
# $php_time = (explode(' ', $php_time))[1];

/* [PHP]
if (time() - $lastMsgTime >= 86400) { // DO STUFF }
[/PHP]

*/

if ($php_time - $java_time >= 86400) { /* DO STUFF */ }
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Very simple solution and it worked of course, thanx!!!

Phil

"Pedro Graca" <he****@hotpop.com> wrote in message
news:c2*************@ID-203069.news.uni-berlin.de...
[ "Followup-To:" set to comp.lang.php ]
Phil Powell wrote:
I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:

> > PHP time (using microtime()): 0.79479900 1079196997

> > Java time: 1079165215886


Good! they look very similar
The Java time is returned to the PHP class method as mixed but could
be converted to float I would think, but how would I ensure that they
would be compared correctly when I do this:


I don't know Java, much less how to integrate it with PHP so I'm just
assuming you get a string variable available in PHP with the Java time:

<?php
$java_time = '1079165215886';
$php_time = '0.79479900 1079196997';

$java_time /= 1000;

$php_time = explode(' ', $php_time);
$php_time = $php_time[1];
## it's a pity you can't do
# $php_time = (explode(' ', $php_time))[1];

/*
[PHP]
if (time() - $lastMsgTime >= 86400) { // DO STUFF }
[/PHP]

*/

if ($php_time - $java_time >= 86400) { /* DO STUFF */ }
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
4
by: Thomas Mann | last post by:
Hi, how can I make my XSLT-stylesheet insert a timestamp (date/time) into the output file ? Regards Thomas
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
17
by: | last post by:
Hello, I need to send a Java date (milliseconds since the epoch 1970-01-01 00:00:00.000 GMT) through a socket to a C++ app and reconstruct exactly the same date in the C++ app as in the Java...
0
by: daniel li | last post by:
I got a runtime error for the following C# code which is converted from java to C# by .net conversion tool. Error: out of range exception "Ticks must be between DataTime.MinValue.Ticks and...
3
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running...
0
by: abhishekbrave | last post by:
Hi, I have to reuse the code given below for displaying a calendar according to the month and year specified by user ...currently this code is fetching systme date and genrating calendar for that......
4
by: abhishekbrave | last post by:
Below is the java code for getting a calendar for current date. I have to reuse it for the month and year entered by user..* My query is how to pass month and year from user and in which format to...
7
by: up2trouble | last post by:
In mysql, I have a field defined as a time stamp. It is storing value as 0000-00-00 00:00:00. It to store it in seconds. <?PHP $entered = mktime(); echo "<INPUT TYPE='text' NAME='$entered'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.