SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Generate 60bit time stamp in PHP

    How to generate 60bit Timestamp in PHP?
    This time stamp should include nanoseconds also.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is microtime what you are looking for?

    http://php.net/manual/en/function.microtime.php
    I'm creating trouble-free Apache, PHP, MySQL installer, WITSuite,
    and use it to setup my development environment.
    Demo, support, contact. Questions?

  3. #3
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Thank you.

    I have a strange requirement here. The timestap is a 60 bit value, representing the number of 100 nanosecond intervals since 15 October 1582 00:00:000000000.

    Refer:
    http://www.famkruithof.net/guid-uuid-timebased.html The timestamp

  4. #4
    SitePoint Member
    Join Date
    Jul 2004
    Location
    us
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ArunB View Post
    Thank you.

    I have a strange requirement here. The timestap is a 60 bit value, representing the number of 100 nanosecond intervals since 15 October 1582 00:00:000000000.

    Refer:
    http://www.famkruithof.net/guid-uuid-timebased.html The timestamp
    Just pad the end of the PHP generated timestamp with the appropriate number of 0s?

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    That page you link to, tells you how to go about it.
    Generally a programmer does not get the current time in 100 nanosecond intervals since 15 October 1582, but for instance in millisecond precision since 1 January 1970. In this case, to come from milliseconds to nanoseconds precision multiply the time returned from the system by 10000 and to correct the start date add an offset of 122192928000000000.
    PHP Code:
    $time = ( time() * 10000 ) + 122192928000000000
    However that may be going over PHP's integer limit...
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    To get around PHP's interger limits look into the GMP library:
    http://us2.php.net/manual/en/book.gmp.php

    BC Math:
    http://us2.php.net/manual/en/book.bc.php

    or Pear's Math Big Integer:
    http://pear.php.net/package/Math_BigInteger
    Last edited by logic_earth; Jul 14, 2008 at 00:04.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •