Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Taking Time...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 26134 of 26821
Post > Topic >>

Re: Taking Time and Date from System in C

by Morris Dovey <mrdovey@[EMAIL PROTECTED] > May 9, 2008 at 02:11 PM

Tameem wrote:
> i am a new C programmer. i want to calculate someone's age. my input
> would be his birth date. like : Date: 07
>         Month: 12
>         Year: 1988
> and the program will take the current date from system and calculate
> his age,
> how can i do that in C. please inform me.

One way is to store those values into a struct tm and use mktime() to 
convert to a time_t value, then pass that value and the current time to 
difftime() to get the person's age in seconds. It's up to you to convert 
that to whatever units (years, months, lunar cycles, etc) you want.

-- 
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
 




 8 Posts in Topic:
Taking Time and Date from System in C
Tameem <etameem@[EMAIL  2008-05-09 11:59:11 
Re: Taking Time and Date from System in C
Morris Dovey <mrdovey@  2008-05-09 14:11:28 
Re: Taking Time and Date from System in C
roberson@[EMAIL PROTECTED  2008-05-09 19:25:13 
Re: Taking Time and Date from System in C
Flash Gordon <spam@[EM  2008-05-09 20:26:56 
Re: Taking Time and Date from System in C
Tameem <etameem@[EMAIL  2008-05-09 13:06:19 
Re: Taking Time and Date from System in C
Morris Dovey <mrdovey@  2008-05-09 15:17:33 
Re: Taking Time and Date from System in C
jacob navia <jacob@[EM  2008-05-09 22:22:51 
Re: Taking Time and Date from System in C
Richard Heathfield <rj  2008-05-09 20:36:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 1:15:47 CDT 2008.