# calculate the seconds elapsed since certain date

Page 1 of 1

## 5 Replies - 2746 Views - Last Post: 28 October 2009 - 12:07 PMRate 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=134992&amp;s=b96963597429145c26c6d779f01ddd93&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 amin_bouma

Reputation: 0
• Posts: 2
• Joined: 26-October 09

# calculate the seconds elapsed since certain date

Posted 28 October 2009 - 07:03 AM

Bonjour,

Je dois calculer le nombre de secondes qui se sont écoulées depuis une certaine date au format JJ/MM/AAAA et HH/MIN/SEC

Je cherche une méthode propre et je pensais utiliser la librairie time.h mais je ne trouve rien qui puisse me correspondre.
Avant de passer à la méthode "bourrine" j'aimerais savoir si quelqu'un à une piste ...

merci

Amine
Is This A Good Question/Topic? 0

## Replies To: calculate the seconds elapsed since certain date

### #2 jeff666

Reputation: 6
• Posts: 193
• Joined: 30-December 08

## Re: calculate the seconds elapsed since certain date

Posted 28 October 2009 - 07:23 AM

This forum is english
For french forum, ask on C / windows programming ng http://minilien.com/?unIaO28zJP
(or others...)

### #3 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

## Re: calculate the seconds elapsed since certain date

Posted 28 October 2009 - 07:58 AM

I understod that??

```time_t a, b, c;
struct tm tmp;

tmp.tm_year = 2000;
tmp.tm_mon = 2;
tmp.tm_mday = 2;
tmp.tm_hour = 6;
tmp.tm_min = 36;
tmp.tm_sec = 15;

a = mktime(&tmp); /* So a = March 2nd, 2000 06:36:15 */

/* Load tmp with another date */

b = mktime(&tmp);

c = a - b; /* c = difference in seconds */

```

### #4 amin_bouma

Reputation: 0
• Posts: 2
• Joined: 26-October 09

## Re: calculate the seconds elapsed since certain date

Posted 28 October 2009 - 08:09 AM

brds, on 28 Oct, 2009 - 06:58 AM, said:

I understod that??

```time_t a, b, c;
struct tm tmp;

tmp.tm_year = 2000;
tmp.tm_mon = 2;
tmp.tm_mday = 2;
tmp.tm_hour = 6;
tmp.tm_min = 36;
tmp.tm_sec = 15;

a = mktime(&tmp); /* So a = March 2nd, 2000 06:36:15 */

/* Load tmp with another date */

b = mktime(&tmp);

c = a - b; /* c = difference in seconds */

```

yes it's totally that ... thank you very much
best regards
A.

### #5 poncho4all

Reputation: 123
• Posts: 1,413
• Joined: 15-July 09

## Re: calculate the seconds elapsed since certain date

Posted 28 October 2009 - 11:42 AM

I bet he understood what he posted when his teacher told him the task.

Wooot?!?

### #6 brds

Reputation: 76
• Posts: 515
• Joined: 22-October 08

## Re: calculate the seconds elapsed since certain date

Posted 28 October 2009 - 12:07 PM

Merde!

Damn sneaky frenchie!

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }