1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Kuala Lumpur, MY
    Rep Power

    different between two time and date

    Hi... i need an idea on how to do this...
    let say i have to time....

    9/20/2002 10:55:35 AM and 9/25/2002 8:30:35 AM

    what is the algorithm to calculate between this to time. I need to know the number of day and time...

  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Woodland Hills, Los Angeles County, California, USA
    Rep Power
    Most programming languages have native date types which are computed as number of seconds since 1970 (or 1980 or 1900 or whatever, depending on your language. Search the web for "epoch date" for more information). They also have a way to convert a date string to the native date type and vice versa. So, all you have to do is convert the date string to an epoch date and then, all you have to do is subtract one date from another, which will give you the difference between the two dates in seconds. After that, it' just a matter of converting the seconds back into days, hours, minutes and seconds.

    Hope this helps.

IMN logo majestic logo threadwatch logo seochat tools logo