Exercise
Date and time
Objetive
Create a program to display the current date and time with the following format:
Today is 6 of February of 2015. It´s 03:23:12
Example Code
// Import the System namespace which provides fundamental classes for date, time, and console operations
using System;
class Program
{
// Main method to execute the program
static void Main()
{
// Get the current date and time
DateTime currentDateTime = DateTime.Now; // Retrieve the current system date and time
// Display the current date and time in the specified format
Console.WriteLine($"Today is {currentDateTime.Day} of {currentDateTime.ToString("MMMM")} of {currentDateTime.Year}. It´s {currentDateTime.ToString("HH:mm:ss")}");
}
}