Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is Date functionality done this way?

    OK, I've been reading the threads on Date stuff with great interest and I've begun to wonder...

    Why do most of y'all code date arithmetic using milliseconds? I'm no expert (yet) but it's clear that using milliseconds is not the only way. Compared to the alternative technique, it's definitely more convoluted looking. So why do it the hard way?

    For example why multiply by 86,400,000 (or whatever it is) when adding a simple integer will increment by any number of days?

    I've seen a very comprehensive javascript date web site and the author says it's "folly" to do date arithmetic using milliseconds.
    http://www.merlyn.demon.co.uk/js-dates.htm

    So how about it? What valid reasons are there one way or the other?
    Last edited by RadarBob; 08-27-2002 at 01:00 AM.

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    because there are built in Date methods that convert Dates to milliseconds. also, a millisecond representation of a date, is exact; you don't have to worry about the format of the date, like MMDDYY or DDMMYY.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    166
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Radar

    For example why multiply by 86,400,000 (or whatever it is) when adding a simple integer will increment by any number of days?

    actually it's 86,400

    60 seconds per minute
    60 minutes per hour
    24 hours per day is

    86,400 seconds per day.

    Another note...
    Atomic time is based on elapsed time in seconds since January 1, 1900

    WebTime - 27-Aug-2002
    ======================
    Started up Microsoft wsock32.dll, ver2.2, 32bit of Jun 7 2000, at 21:34:15.
    Socket 52 created
    Connecting to Boulder, Colorado - A
    URL is time-a.timefreq.bldrdoc.gov
    At IP Address 132.163.4.101
    Connected to Boulder, Colorado - A
    URL is time-a.timefreq.bldrdoc.gov
    At IP Address 132.163.4.101
    Waiting to receive ...
    Received elapsed time of 3239420060 seconds since January 1, 1900
    System date and time successfully changed
    From: 27-Aug-2002 - 01:54:19.690
    To: 27-Aug-2002 - 01:54:19.970
    Socket closed.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's a good question actually. I can only speak for myself and for me, it's definitely a matter of too long exposure to PHP scripting... PHP doesn't have Date objects comparable to JavaScript. Also, when transforming a date into it's milisecond value, I have the feeling that I'm very exact now cause I'm sort-of dealing with the "lowest common denominator". Which is just plain wrong, but I tend to forget that most of the time

    But there are really uses of comparing dates in miliseconds - even the page you posted contains examples of these (for instance, trying to find out how many days elapsed between two Date objects). The author only said that it's a folly to

    Using millisecond arithmetic where daycount arithmetic is appropriate
    So there may be occasions where daycount arithmetic is not appropriate. And vice versa of course.

    Will be using more daycount arithmetic in the future I think. Well, only if I think it's appropriate.


  •  

    Posting Permissions

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