yy (without caps) : represent last two alphabet of the year. ex for 2014 it will represent 14.
*In formatting operations, custom date and time format strings can be used either with the ToString method of a date and time instance or with a method that supports composite formatting.
* Syntax for the programmer to represent date in his/her own format.
Console.WriteLine("Today is " +Date1.ToString("ddd yy, MMMM") );
* DateTimeOffset is the class which is used for both date & time.
* General format of the date is Year, Month, Day, Hour, Minute, Second & timespan.
For example DateTimeOffset Date2 = new DateTimeOffset(2011, 6, 10, 15, 24, 16,
TimeSpan.Zero);
*Programmer can represent the date in his/her own format by keeping the basic format in their mind
H: Hour mm:Minute ss : Second zzz : TimeSpan
* Syntax for the programmer to represent date & time in his/her own format
Console.WriteLine (" date and time:{0:MM/dd/yy H:mm:ss zzz}", Date2);
Here is the complete program to implement the date and time logic :
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication12 { classProgram { staticvoid Main(string[] args) { DateTime date1 = newDateTime(2016,09,14);// year month and day Console.WriteLine("Today is " + date1.ToString("ddd yy, MMMM")); DateTimeOffset Date2 = newDateTimeOffset(2016,09,14, 15, 24, 16, newTimeSpan(1,0,0)); Console.WriteLine(" date and time: {0:MM/dd/yy H:mm:ss zzz}", Date2); Console.ReadLine(); } } }
Liked By
Write Answer
What is a basic concept of date and time
Join MindStick Community
You have need login or register for voting of answers or question.
Elena Glibart
14-Sep-2016Here is a basic concept of data and time
* DateTime is the class which is already defined in the system.
* General format of the date is Year month and day.
For example: DateTime Date1 = new DateTime(2014, 02, 01);
In the above example below are the input which is already define by the programmer:
Year : 2014
Month: (02) February
Day : 01
* Representation of the date:
Programmer can represent the date in his/her own format by keeping the basic format in their mind
MMMM (in caps):- full name of the month. eg September
MMM (in caps):- short name of the month. eg. Sept
MM (in caps):- Month in number
dddd (without caps) :- full name of the day. eg Saturday
ddd (without caps) :- short name of the day. eg. Sat
dd (without caps) :- day in number
yyy & yyyy (without caps) means : represent year. ex. 2014
yy (without caps) : represent last two alphabet of the year. ex for 2014 it will represent 14.
*In formatting operations, custom date and time format strings can be used either with the ToString method of a date and time instance or with a method that supports composite formatting.
* Syntax for the programmer to represent date in his/her own format.
Console.WriteLine("Today is " +Date1.ToString("ddd yy, MMMM") );
* DateTimeOffset is the class which is used for both date & time.
* General format of the date is Year, Month, Day, Hour, Minute, Second & timespan.
For example DateTimeOffset Date2 = new DateTimeOffset(2011, 6, 10, 15, 24, 16,
TimeSpan.Zero);
*Programmer can represent the date in his/her own format by keeping the basic format in their mind
* Syntax for the programmer to represent date & time in his/her own format
Here is the complete program to implement the date and time logic :