C Programming Exercises, Practice, Solution : Date Time
C Date Time [10 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a program in C to print the current date and time.
Expected Output :
The Current date and time is : Thu Aug 03 13:38:58 2017
2. Write a program in C to compute the number of seconds passed since the beginning of the month.
Expected Output :
222084 seconds passed since the beginning of the month.
3. Write a program in C to convert a time_t object to a textual representation.
Expected Output :
Thu Aug 03 13:44:49 2017
4. Write a program in C to convert a tm object to a custom textual representation.
Expected Output :
The textual representation of specified date and time : September Sun Sep 2 16:30:32 2016 pm September Sun Sep 2 16:30:32 2016 pm
5. Write a program in C to convert a tm object to a custom wide string textual representation.
Expected Output :
The textual representation of specified date and time : Sunday 09/02/16 17:51:10 Sunday 09/02/16 17:51:10
6. Write a program in C to convert a time_t object to calendar time expressed as Coordinated Universal Time.
Expected Output :
The calendar time expressed as Coordinated Universal Time is : UTC: Thu Aug 03 10:53:03 2017 local: Thu Aug 03 16:23:03 2017
7. Write a program in C to convert a time_t object to calendar time expressed as local time.
Expected Output :
The calendar time expressed as a local Time is : UTC: Thu Aug 03 11:15:59 2017 local: Thu Aug 03 16:45:59 2017
8. Write a program in C to print the date and time before 24 months.
Expected Output :
Today is : Thu Aug 3 17:27:16 2017 (DST is not in effect) 24 months ago the date was : Mon Aug 3 17:27:16 2015 (DST was not in effect)
9. Write a program in C to show the first of calendar time.
Expected Output :
Sun Jan 01 00:00:00 1900
10. Write a program in C to show the start of the epoch.
Note : epoch means the beginning of a period in the history of someone.
Expected Output :
0 seconds since the epoch began Thu Jan 01 00:00:00 1970
C Programming Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/c-programming-exercises/datetime/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics