# Date and Time Difference Calculator

Page 1 of 1

## 3 Replies - 8202 Views - Last Post: 29 March 2010 - 12:06 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=164699&amp;s=5bc0a9e0e7607f9156f7a54c9f4f5c82&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Tapas Bose

• D.I.C Regular

Reputation: 23
• Posts: 472
• Joined: 09-December 09

# Date and Time Difference Calculator

Posted 28 March 2010 - 04:08 AM

I am writing a code whose job is to calculate difference between two given date and time. The format will be
YYYY:MM:DD:hh:mm:ss, ISO standard. As Gregorian Calendar proclaimed in 1582, what will be the lower limit of year, year 0001? I set the upper limit of year as year 9999.

This post has been edited by Tapas Bose: 28 March 2010 - 04:10 AM

Is This A Good Question/Topic? 0

## Replies To: Date and Time Difference Calculator

### #2 r.stiltskin

• D.I.C Lover

Reputation: 1833
• Posts: 4,927
• Joined: 27-December 05

## Re: Date and Time Difference Calculator

Posted 28 March 2010 - 09:13 AM

Tapas Bose, on 28 March 2010 - 07:08 AM, said:

... what will be the lower limit of year, year 0001?

Doesn't that depend on the intended use of the program? If the user needs to deal with events in, say, the Roman Empire or the medieval period then you should write code that is able to handle the Gregorian transition, but if the user will only be dealing with modern times that would be a waste of effort.

### #3 Tapas Bose

• D.I.C Regular

Reputation: 23
• Posts: 472
• Joined: 09-December 09

## Re: Date and Time Difference Calculator

Posted 28 March 2010 - 09:29 AM

Thank you. I understand your point. Following is a sample output of my code :
```  Date and Time difference calculator.
Format : YYYY:MM:DD:hh:mm:ss.
Range : 0001:01:01:00:00:00 - 9999:12:31:23:59:59.

Enter From Date : 0001:01:01:00:00:00
Enter To Date : 9999:12:31:23:59:59

The Difference is : 521722 weak 4 day 23 hour 59 minute 59 second.
Or,
The Difference is : 3652058 day 23 hour 59 minute 59 second.
Or,
The Difference is : 87649415 hour 59 minute 59 second.
Or,
The Difference is : 963997663 minute 59 second.
Or,
Difference is : 2005284991 second.

```

If you want to see the code. I can post it here.

Reputation:

## Re: Date and Time Difference Calculator

Posted 29 March 2010 - 12:06 AM

[/code]
If you want to see the code. I can post it here.
[/quote]

yes,please.i would be grateful if you could post the code for this program.