国产探花免费观看_亚洲丰满少妇自慰呻吟_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"


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 舞钢市| 永德县| 信丰县| 郓城县| 彭州市| 福州市| 库车县| 南城县| 通州区| 新巴尔虎右旗| 云南省| 申扎县| 洛扎县| 旬邑县| 客服| 八宿县| 昌邑市| 泰来县| 陆良县| 高雄市| 屯昌县| 延边| 伊川县| 阳泉市| 潞城市| 额济纳旗| 泸定县| 大足县| 浦县| 婺源县| 长宁区| 大同县| 铜川市| 普安县| 新龙县| 疏附县| 临洮县| 建昌县| 依兰县| 依兰县| 宣武区|