Locked lesson.
About this lesson
We introduce the Datetime data type and explain how to set it to a specific value.
Exercise files
Download this lesson’s related exercise files.
7 - Datetime.docx60.7 KB 7 - Datetime SOLUTION.docx
57.6 KB
Quick reference
Datetime
Datetime is another Data Type.
When to use
Datetime is used when you need to deal with a date or a time.
Instructions
- DateTime myDate = new DateTime();
- Return a specific date (October 14, 2021):
DateTime myDate = new DateTime(2021, 10, 14); - Return Current Date:
DateTime myDate = DateTime.Today; - Return Current Date and Time:
DateTime myDate = DateTime.Now;
Lesson notes are only available for subscribers.