Skip to content

Latest commit

 

History

History
75 lines (54 loc) · 1.87 KB

DateTime.md

File metadata and controls

75 lines (54 loc) · 1.87 KB

Datetime

  1. Write a program to display the:
a) Current date and time
b) Current year
c) Month of year
d) Week number of the year
e) Weekday of the week
f) Day of year
g) Day of the month
h) Day of week
j) if the current year is a leap year or not
  1. Write a program to add N year(s) to the current date and display the new date.

  2. Write a program to display the date and time in a human-friendly string.

  3. Write a program to add 5 seconds to the current time and print it to the console.

*5. Write a program to get current time in milliseconds.

  1. Write a program that calculates the date six months from the current date.

  2. Write a program to get the first and last second of a day.

*8. Write a program to calculate two date difference in seconds.

  1. Given a date of birth, calculate the age of a person.
        Input: 10, 09, 1989 
        Output: 29

Note: Requires parsing a string to make it a date. Get to me on slack to give you resources for this.

  1. Write a program to get the dates 30 days before and after from the current date, and display it to the console

  2. Write a program to calculate a number of days between two dates.

  3. Write a program to print yesterday, today, tomorrow.

      Yesterday :  2017-05-05 
      Today :  2017-05-06                  
      Tomorrow :  2017-05-0
  1. Write program to print next 5 days starting from today.

*11. Write a program to find the date of the first Monday of a given week

      Input  : 2015, 50
      Output : Mon Dec 14 00:00:00 2015      

*12. Write a program to get days between two dates.

    Input :  
    2000,2,2
    2001,2,28
    Output : 366 days, 0:00:00

*13. Write a program to select all the Sundays of a specified year and display their dates

      Output:
      2020-01-05
      2020-01-12 
      2020-01-19