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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    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
  • Pedro Graca

    #2
    Re: PHP timestamp comparison with java.util.Date. getTime() timestamp

    [ "Followup-To:" set to comp.lang.php ]
    Phil Powell wrote:[color=blue]
    > 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
    >
    [/color]

    Good! they look very similar
    [color=blue]
    > 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:[/color]

    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];

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

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

    Comment

    • Phil Powell

      #3
      Re: PHP timestamp comparison with java.util.Date. getTime() timestamp

      Very simple solution and it worked of course, thanx!!!

      Phil

      "Pedro Graca" <hexkid@hotpop. com> wrote in message
      news:c2vfqs$21t ojo$1@ID-203069.news.uni-berlin.de...[color=blue]
      > [ "Followup-To:" set to comp.lang.php ]
      > Phil Powell wrote:[color=green]
      > > 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
      > >
      [/color]
      >
      > Good! they look very similar
      >[color=green]
      > > 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:[/color]
      >
      > 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];
      >
      > /*[color=green]
      > > [PHP]
      > > if (time() - $lastMsgTime >= 86400) { // DO STUFF }
      > > [/PHP][/color]
      > */
      >
      > if ($php_time - $java_time >= 86400) { /* DO STUFF */ }
      > ?>
      > --
      > --= my mail box only accepts =--
      > --= Content-Type: text/plain =--
      > --= Size below 10001 bytes =--[/color]


      Comment

      Working...