|
-
April 24th, 1999, 01:20 PM
#1
C Program to display time left til Year 2000
Does anybody have a C program that prompts the user for a date and returns the time left to the year 2000 (from the date the user entered)?
-
April 25th, 1999, 02:15 AM
#2
Re: C Program to display time left til Year 2000
The time command gives the number of seconds that have passed
since midnight, Greenwich time, Jan 1 1970. Figure out how many
seconds from then to Y2K and subtract (time), and you've got it.
Cheers,
Jason F.
[email protected]
-
April 25th, 1999, 09:20 PM
#3
Re: C Program to display time left til Year 2000
I hate to sound like an idiot, although when it comes to programming I must admit I am. Anyway, do you have any examples using this command. I've tried doing some things, but am not having much success.
Jody
-
April 26th, 1999, 08:37 AM
#4
Re: C Program to display time left til Year 2000
Ok, I king of figured out the time command.
How do I use the time command with a date and time entered from the keyboard, instead of it using the current system date/time??
-
April 26th, 1999, 12:40 PM
#5
Re: C Program to display time left til Year 2000
Try mktime. You first fill in a tm structure and it converts it to a time_t value.
-
April 27th, 1999, 11:16 AM
#6
Re: C Program to display time left til Year 2000
It's easy with MFC. Start a new project in VC 6. Select "Console app with MFC support." Enter this in the "to do" section:
CTime curtime(CTime::GetCurrentTime());
CTime time2000(2000,1,1,0,0,0);
CTimeSpan remaining = time2000 - curtime;
CString outpt;
outpt.Format("Time left until armageddon: %d days, %d hours, %d minutes, %d seconds", remaining.GetDays(), remaining.GetHours(), remaining.GetMinutes(), remaining.GetSeconds());
cout << (LPCTSTR)outpt << endl;
mailto:[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|