国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

日期和時間的轉換

2024-07-21 02:16:37
字體:
來源:轉載
供稿:網友
,歡迎訪問網頁設計愛好者web開發。the datetime data type also contains a format method and a tostring method that return a string-formatted representation of the original value. the format method can be used to format a value in one of fifteen common ways, while the tostring method can only be used to format a value in one way.

the format method takes the following form, where xxx is the name of the numeric base data-type:

virtual xxx format(string* format,iserviceobjectprovider* sp)
similar to the format methods found in other .net framework data types, the datetime format method takes a string format character and an iserviceobjectprovider object. the iserviceobjectprovider object specifies the culture. the method defaults to the current culture if null (in visual basic nothing) is passed.

the following table shows the valid format strings.


format character description default return format
d short date pattern mm/dd/yyyy
d long date pattern dddd, mmmm dd, yyyy
f full (long date + short time) dddd, mmmm dd, yyyy hh:mm
f full date time pattern (long date + long time) dddd, mmmm dd, yyyy hh:mm:ss
g general (short date + short time) mm/dd/yyyy hh:mm
g general (short date + long time) mm/dd/yyyy hh:mm:ss
m,m month day pattern mmmm dd
r,r rfc1123 pattern  ddd, dd mmm yyyy hh':'mm':'ss'gmt'
s sortable date time pattern: conforms to iso 8601 yyyy-mm-dd hh:mm:ss
t short time pattern hh:mm
t long time pattern hh:mm:ss
u similar to "s"but uses universal time instead of local time. yyyy-mm-dd hh:mm:ss
u universal sortable date time pattern dddd, mmmm dd, yyyy hh:mm:ss
y,y year month pattern mmmm, yyyy


given a datetime object, mydate, representing 12:01 am sunday, january 1, 2000, the following example illustrates some of the formatting options available:

[c#]
mydate.format( "d", null );
// returns the string "01/01/2000"

mydate.format( "d", null );
// returns the string "sunday, january 1, 2000"

mydate.format( "f", null );
// returns the string "sunday january 1, 2000 12:01 am"
the tostring method will quickly convert a datetime type value into a string. similar to other .net framework base types, it requires no arguments and is easy to use. unlike the format method, the tostring method is unaffected by the current culture and only takes one form. the following example converts a datetime value into a string value:

[c#]

datetime mydate = new datetime(2000, 01, 01)
mydate.tostring();
//returns "01/01/2000 00:00:00"


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 疏勒县| 恩平市| 哈密市| 临沂市| 阳山县| 澄迈县| 辛集市| 柏乡县| 板桥市| 漳州市| 伊吾县| 安义县| 个旧市| 宣城市| 扶风县| 广南县| 万源市| 余姚市| 大渡口区| 石狮市| 滕州市| 宜君县| 沅江市| 内黄县| 淮南市| 鄂尔多斯市| 光山县| 临安市| 巴塘县| 鸡东县| 涟水县| 中卫市| 丹阳市| 海宁市| 禹城市| 义马市| 老河口市| 孙吴县| 岐山县| 延津县| 本溪|