This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18905|Reply: 0

[WinForm] Use of DateTime

[Copy link]
Posted on 12/11/2019 12:09:34 PM | | |
DateTime dt = DateTime.Now;

    StringBuilder sb = new StringBuilder();
    sb. AppendLine(string. Format("DataTime string represents: {0}", dt. ToString()));

    sb. AppendLine(string. Format("Year portion of DataTime: {0}", dt. Year));
    sb. AppendLine(string. Format("Month part of DataTime: {0}", dt. Month));
    sb. AppendLine(string. Format("Date portion of DataTime: {0}", dt. Date));
    sb. AppendLine(string. Format("Hourly part of DataTime: {0}", dt. Hour));
    sb. AppendLine(string. Format("Minute portion of DataTime: {0}", dt. Minute));
    sb. AppendLine(string. Format("Second part of DataTime: {0}", dt. Second));
    sb. AppendLine(string. format("millisecond portion of DataTime: {0}", dt. Millisecond));

    sb. AppendLine(string. Format("DataTime is the day of the month: {0}", dt. Day));
    sb. AppendLine(string. Format("DataTime is the day of the week: {0}", dt. DayOfWeek));
    sb. AppendLine(string. Format("DataTime is the day of the year: {0}", dt. DayOfYear));
    sb. AppendLine(string. Format("DataTime gets the time portion of the day (TimeSpan format): {0}", dt. TimeOfDay));

    sb. AppendLine(string. Format("DateTime converts to 64-bit binary: {0}", dt. ToBinary()));
    sb. AppendLine(string. Format("DateTime to Windows File Time: {0}", dt. ToFileTime()));
    sb. AppendLine(string. Format("DateTime to UTC Windows File Time: {0}", dt. ToFileTimeUtc()));
    sb. AppendLine(string. Format("DateTime converts to local time: {0}", dt. ToLocalTime()));
    sb. AppendLine(string. Format("DateTime converted to OLE automation date: {0}", dt. ToOADate()));
    sb. AppendLine(string. Format("DateTime to UTC Time: {0}", dt. ToUniversalTime()));

    sb. AppendLine(string. Format("DateTime converts to long date form: {0}", dt. ToLongDateString()));
    sb. AppendLine(string. Format("DateTime converts to short date form: {0}", dt. ToShortDateString()));
    sb. AppendLine(string. Format("DateTime converts to long-term form: {0}", dt. ToLongTimeString()));
    sb. AppendLine(string. Format("DateTime converts to short-time form: {0}", dt. ToShortTimeString()));

    Console.WriteLine(sb. ToString());





Previous:C# multithreaded development
Next:Personal English dictionary usage experience
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com