c#

位置:IT落伍者 >> c# >> 浏览文章

c# string.Format格式化日期


发布日期:2018年09月25日
 
c# string.Format格式化日期

DateTime dt = DateTimeNow;

LabelText = dtToString();// ::

LabelText = dtToFileTime()ToString();//

LabelText = dtToFileTimeUtc()ToString();//

LabelText = dtToLocalTime()ToString();// ::

LabelText = dtToLongDateString()ToString();//*

LabelText = dtToLongTimeString()ToString();//::

LabelText = dtToOADate()ToString();//

LabelText = dtToShortDateString()ToString();//

LabelText = dtToShortTimeString()ToString();//:

LabelText = dtToUniversalTime()ToString();// ::

? ::

LabelText = dtYearToString();//

LabelText = dtDateToString();// ::

LabelText = dtDayOfWeekToString();//Saturday

LabelText = dtDayOfYearToString();//

LabelText = dtHourToString();//

LabelText = dtMillisecondToString();//

LabelText = dtMinuteToString();//

LabelText = dtMonthToString();//

LabelText = dtSecondToString();//

LabelText = dtTicksToString();//

LabelText = dtTimeOfDayToString();//::

LabelText = dtToString();// ::

LabelText = dtAddYears()ToString();// ::

LabelText = dtAddDays()ToString();// ::

LabelText = dtAddHours()ToString();// ::

LabelText = dtAddMilliseconds()ToString();// ::

LabelText = dtAddMonths()ToString();// ::

LabelText = dtAddSeconds()ToString();// ::

LabelText = dtAddMinutes()ToString();// ::

LabelText = dtAddTicks()ToString();// ::

LabelText = dtCompareTo(dt)ToString();//

//LabelText = dtAdd(?)ToString();//问号为一个时间段

LabelText = dtEquals( ::)ToString();//False

LabelText = dtEquals(dt)ToString();//True

LabelText = dtGetHashCode()ToString();//

LabelText = dtGetType()ToString();//SystemDateTime

LabelText = dtGetTypeCode()ToString();//DateTime

LabelText = dtGetDateTimeFormats(s)[]ToString();//T::

LabelText = dtGetDateTimeFormats(t)[]ToString();//:

LabelText = dtGetDateTimeFormats(y)[]ToString();//

LabelText = dtGetDateTimeFormats(D)[]ToString();//*

LabelText = dtGetDateTimeFormats(D)[]ToString();//

LabelText = dtGetDateTimeFormats(D)[]ToString();//星期六

LabelText = dtGetDateTimeFormats(D)[]ToString();//星期六 *

LabelText = dtGetDateTimeFormats(M)[]ToString();//*

LabelText = dtGetDateTimeFormats(f)[]ToString();//* :

LabelText = dtGetDateTimeFormats(g)[]ToString();// :

LabelText = dtGetDateTimeFormats(r)[]ToString();//Sat Nov :: GMT

或者dtToString(yyyy年MM月dd*);//*

dtToString(yyyyMMdd);//*

以此类推……

LabelText =? stringFormat(:d}dt);//

LabelText =? stringFormat(:D}dt);//*

LabelText =? stringFormat(:f}dt);//* :

LabelText =? stringFormat(:F}dt);//* ::

LabelText =? stringFormat(:g}dt);// :

LabelText =? stringFormat(:G}dt);// ::

LabelText =? stringFormat(:M}dt);//*

LabelText =? stringFormat(:R}dt);//Sat Nov :: GMT

LabelText =? stringFormat(:s}dt);//T::

LabelText = stringFormat(:t}dt);//:

LabelText = stringFormat(:T}dt);//::

LabelText = stringFormat(:u}dt);// ::Z

LabelText = stringFormat(:U}dt);//* ::

LabelText = stringFormat(:Y}dt);//

LabelText = stringFormat(dt);// ::?

LabelText = stringFormat(:yyyyMMddHHmmssffff}dt); //yyyymm等可以设置比如LabelText = stringFormat(:yyyyMMdd}dt);

绑定也适用:例:<%# stringFormat(:yyyyMMdd}eval_r(sj))%>

               

上一篇:用C#.net轻松制作不规则窗体

下一篇:C#如何去掉字符串中所有空格