| | |
Checking on Date and Time (C#)
Please support our C# advertiser: Intel Parallel Studio Home
Is it Mother Date and Father Time? Any way, getting all the different date and time displays working can be imperturbably perplexing at times. You take a look at it in this Windows Console Application.
// retrieve and format date/time data // tested with VCS.NET 2003 using System; // has all the date/time stuff class myApp { public static void Main() { DateTime CurrTime = DateTime.Now; Console.WriteLine("DateTime display listing specifier and result:\n"); Console.WriteLine("d = {0:d}", CurrTime ); // Short date mm/dd/yyyy Console.WriteLine("D = {0:D}", CurrTime ); // Long date day, month dd, yyyy Console.WriteLine("f = {0:f}", CurrTime ); // Full date/short time day, month dd, yyyy hh:mm Console.WriteLine("F = {0:F}", CurrTime ); // Full date/full time day, month dd, yyyy HH:mm:ss AM/PM Console.WriteLine("g = {0:g}", CurrTime ); // Short date/short time mm/dd/yyyy HH:mm Console.WriteLine("G = {0:G}", CurrTime ); // Short date/long time mm/dd/yyyy hh:mm:ss Console.WriteLine("M = {0:M}", CurrTime ); // Month dd Console.WriteLine("R = {0:R}", CurrTime ); // ddd Month yyyy hh:mm:ss GMT Console.WriteLine("s = {0:s}", CurrTime ); // yyyy-mm-dd hh:mm:ss can be sorted! Console.WriteLine("t = {0:t}", CurrTime ); // Short time hh:mm AM/PM Console.WriteLine("T = {0:T}", CurrTime ); // Long time hh:mm:ss AM/PM Console.WriteLine("u = {0:u}", CurrTime ); // yyyy-mm-dd hh:mm:ss universal/sortable Console.WriteLine("U = {0:U}", CurrTime ); // day, month dd, yyyy hh:mm:ss AM/PM Console.WriteLine("Y = {0:Y}", CurrTime ); // Month, yyyy Console.WriteLine(); Console.WriteLine("DateTime.Month = " + CurrTime.Month); // number of month Console.WriteLine("DateTime.DayOfWeek = " + CurrTime.DayOfWeek); // full name of day Console.WriteLine("DateTime.TimeOfDay = " + CurrTime.TimeOfDay); // 24 hour time // number of 100-nanosecond intervals that have elapsed since 1/1/0001, 12:00am // useful for time-elapsed measurements Console.WriteLine("DateTime.Ticks = " + CurrTime.Ticks); Console.Read(); // wait } }
0
•
•
•
•
It should be also mentioned that you can combine these as in
- for 13/12/2007 5:04 PM as an example
http://www.freebiesms.co.uk
DateTime.Now.ToString("dd/MM/yyyy h:MM tt")- for 13/12/2007 5:04 PM as an example
http://www.freebiesms.co.uk
0
•
•
•
•
Hi,
May I know how to make the following comparison:
A(Date/Time) + B(Integer, in HOUR) <= C.
if after A+B is next day of the date A then is should be increase one day then only compare with C.
How can I make it !!
Thanks in advance
May I know how to make the following comparison:
A(Date/Time) + B(Integer, in HOUR) <= C.
if after A+B is next day of the date A then is should be increase one day then only compare with C.
How can I make it !!
Thanks in advance
Similar Threads
- checking for date created/last modified (C#)
- I want to retrieve only date from date/time (JSP)
- newbie question regarding checking date of file (Shell Scripting)
- convert date(string) to date (date time) (JavaScript / DHTML / AJAX)
- Date calculation and checking. (VB.NET)
| Thread Tools | Search this Thread |
Tag cloud for date, format, time
abrupt ada age alarm birth bluray bmp c++ calculator class click clock clocks code compile conversion convert css date date/time datepart datetime design digital drive dual dvd exam exe firefox form format geek hd html ide image introduction introductory java jpeg lapse layer linux math mysql news numbers partition php professor proficiency program py py2exe python reference retrieve save schedule sony source staticmembers string studio test time timespan tlapse tutorial university unix unreadable vb vb6 video vista visual war wxpython year




