SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: The Unix Epoch

  1. #1
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the The Unix Epoch? isn't it the 1st of January 1970 or something. Whats so special about it and why does PHP use it in its time() function?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know it is the day they started counting the number of seconds to base the unix timestamp off of. if you were to print time() it would give you a number that is the number of seconds since the Epoch or 12:00 am on Jan 1, 1970

    That had to start somewhere, right?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    That had to start somewhere, right?
    Yeah I suppose, but why doesn't the time() function just return the current time according to the server its on instead of counting the number of seconds since the Unix Epoch


  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well then how would time() be accuarte since servers live all over the world, by basing it off one clock you can have universal time that is the same no matter where the physical location of the server is.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The same time() you are using is how the server is basing its time. Computer do not know time, minutes, seconds or hours. They do know that the crystal oscillates at a particular rate per milliseconds. But counting those oscillations it can approximate true time keeping. The epoch is hard coded into the BIOS so the computer has somewhere to start from. When you change the time on the server, you are overriding that hardcoded value with a new one from the CMOS (PRAM or whatever else your architecture calls it). If for some reason the CMOS gets wiped, i.e. battery dies, the computer will revert to hardcoded time so that it has a starting point to base time off of. The date is arbitrary and set by the computer manufacturer. It could be zero but then people would get confused so they picked a real date.

    Most if not all computers use that date as the Epoch. It was the dawn of modern computing. (not sure if that is true but it sounds cool doesn't it?)
    Wayne Luke
    ------------


  6. #6
    SitePoint Evangelist
    Join Date
    May 2000
    Location
    Canada
    Posts
    533
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, it doesnt really matter WHAT epoch is ... the point is it gives a fixed time when time STARTS , as far as the computer is concerned, and can be used to relate times... see difference between times, etc

    --------------------------
    "i'll get you medicine, when you're tummy aches, build you a fire if the furnace breaks, oh, it could be so nice, growing old with you" ... guess the song
    http://www.kryogen.com


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
  •