Mytestbook_no3_text - BestLightNovel.com
You’re reading novel Mytestbook_no3_text No1 Chapter online at BestLightNovel.com. Please use the follow button to get notification about the latest chapter next time when you visit BestLightNovel.com. Use F11 button to read novel in full-screen(PC only). Drop by anytime you want to read free – fast – latest novel. It’s great if you could leave a comment, share your opinion about the new chapters, new novel with others on the internet. We’ll do our best to bring you the finest, latest novel everyday. Enjoy
System.DateTime currentTime=new System.DateTime ();
Take the current year, month, day, hour, minute, second, current time= System.DateTime.Now ;
Take the current year int= currentTime.Year ;
Take current month int month= currentTime.Month ;
Take the current day int= currentTime.Day ;
Take the current time int= currentTime.Hour ;
Take the current score of int= currentTime.Minute ;
Take current seconds int seconds= currentTime.Second ;
Take current MS int MS= currentTime.Millisecond ; (variables can be in Chinese)
Display date in Chinese= currentTime.ToString ("F"); / / do not display seconds
Display date in Chinese_ Month and year string strym= currentTime.ToString ("y");
Display date in Chinese_ Month day string strmd= currentTime.ToString ("m");
Take the current year, month and day, the format is: 2003-9-23 string strymd= currentTime.ToString ("d");
Take the current time, the format is: 14:24 string strt= currentTime.ToString ("t");
DateTime.Now.ToString (); / / get the complete date and time of the current system time
DateTime.Now.ToLongDateString (); / / only the date is displayed, one is a long date
DateTime.Now.ToShortDateString (); / / only the date x.x.x XX XX is displayed, one of which is a short date
//Today DateTime.Now.Date .ToShortDateString();
//Yesterday's DateTime.Now.AddDays (-1).ToShortDateString();
//Tomorrow's DateTime.Now.AddDays (1).ToShortDateString();
//This week (note that every week here starts on Sunday and ends on Sat.u.r.day)
DateTime.Now.AddDays ( Convert.ToDouble ((0 - Convert.ToInt16 ( DateTime.Now.DayOfWeek )))).ToShortDateString();
DateTime.Now.AddDays ( Convert.ToDouble ((6 - Convert.ToInt16 ( DateTime.Now.DayOfWeek )))).ToShortDateString();
//Last week, last week is this week, minus seven days
DateTime.Now.AddDays ( Convert.ToDouble ((0 - Convert.ToInt16 ( DateTime.Now.DayOfWeek ))) - 7).ToShortDateString();
DateTime.Now.AddDays ( Convert.ToDouble ((6 - Convert.ToInt16 ( DateTime.Now.DayOfWeek ))) - 7).ToShortDateString();
//Add seven more days next week this week
DateTime.Now.AddDays ( Convert.ToDouble ((0 - Convert.ToInt16 ( DateTime.Now.DayOfWeek ))) + 7).ToShortDateString();
DateTime.Now.AddDays ( Convert.ToDouble ((6 - Convert.ToInt16 ( DateTime.Now.DayOfWeek ))) + 7).ToShortDateString();
//The first day of this month is the 1st of this month, and the last day is the 1st of the next month, and another day will be deducted.
DateTime.Now.Year .ToString() + DateTime.Now.Month . tostring() + "1"; / / day 1
DateTime.Pa.r.s.e ( DateTime.Now.Year .ToString() + DateTime.Now.Month . tostring() + "1"). Addmonths (1). Adddays (- 1). Toshortdatestring(); / / last day
Another method:
DateTime now = DateTime.Now ;
DateTime d1 = new DateTime( now.Year , now.Month , 1); / / first day of the month
Datetime D2 = D1. Addmonths (1). Adddays (- 1); / / last day of the month
PS:
DateTime.Now.DayOfWeek . tostring(); / / English week display, Wednesday
(int) DateTime.Now.DayOfWeek Number, if it's Wednesday, the result is 3
DateTime.Now.ToString ("dddd", new System.Globalization.CultureInfo ("zh CN"); / / Chinese week display
DateTime.Now.ToString ("dddd"); / / Chinese week display
DateTime.Now.ToString ("dddd,MMMM,dd ,yyyy", new System.Globalization.DateTimeFormatInfo ()); / / display date format: Friday, July, 012009
DateTime.Now.ToString ("dddd, DD mmmm, yyyy") / / output Wednesdays, 30 January, 2008
source: http://msdn.microsoft.com/zh-cn/vstudio/bb762911 (vs.95). ASPX, how to: extract the day of the week from a specific date
Format setting of datetime type in tostring() format
Detailed usage of parameter format format
Format character a.s.sociation property / description
d ShortDatePattern
D LongDatePattern
F full date and time (long date and short time)
F fulldatetimepattern (long date and long time)
G general (short date and short time)
G general (short date and long time)
m、M MonthDayPattern
r、R RFC1123Pattern
S sortabledatetimepattern using local time (based on ISO 8601)
t ShortTimePattern
T LongTimePattern
U universal sortable datetimepattern the format used to display the universal time
U full date and time using universal time (long date and long time)
y、Y YearMonthPattern
The following table lists the patterns that can be merged to construct custom patterns. These patterns are case sensitive
One day in D. Single digit dates have no leading zeros.
DD a day in the month. A single digit date has a leading zero.
Abbreviated name of a day in the DDD week, defined in abbreviated daynames.
Dddd the full name of the day of the week, defined in daynames.
M month number. Single digit months have no leading zeros.
Mm month number. A single digit month has a leading zero.
The abbreviated name of the MMM month, defined in abbreviated monthnames.
The full name of the mmmm month, defined in monthnames.
Y does not include the year of the era. If the year without an era is less than 10, years without leading zeros are displayed.
YY does not contain the year of the era. If the year without era is less than 10, the year with leading zeros is displayed.
Yyyy includes the four digit year of the era.
GG period or era. If the date to be formatted does not have an a.s.sociated period or era string, the pattern is ignored.
H 12 hour system