C # Time-related methods,
Current computer time:
DateTime. now // The current time DateTime. now. toLongDateString (); // display Date: xxxx-xx, one is the Chinese Date DateTime. now. toShortDateString (); // display date xxxx-xx DateTime. now. addDays (-1): Yesterday DateTime. now. addDays (1): Tomorrow
Get current: [timing is not reliable with the current millisecond, different from Java]
Int year = DateTime of the current year. now. year; the current month int month = DateTime. now. month; int day = DateTime of the current day. now. day; int = DateTime. now. hour; int = DateTime. now. minute; int seconds = DateTime. now. second; current millisecond int millisecond = DateTime. now. millisecond;
Convert to a string in different formats:
DateTime. Now. ToString (""): 2016/7/12 15: 47: 17DateTime. Now. ToString ("y"): July 2016
DateTime. Now. ToString ("f"): July 12, 2016
DateTime. Now. ToString ("m"): July 12
DateTime. Now. ToString ("d"): 2016/7/12 DateTime. Now. ToString ("t"): 15: 44