NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

 

[formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

 

NSString *locationString=[formatter stringFromDate: [NSDate date]];



 

//獲取目前時間作為productId

 

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

 

[formatter setDateFormat:@"hhmmss"];

 

NSString *locationString=[formatter stringFromDate: [NSDate date]];

 

downloadInfo.productId = locationString;

 

[formatter release];

 

/******************************************************************************

 

函數名稱 : getDate

 

函數描述 : 獲取當前日期時間

 

輸入參數 : N/A

 

輸出參數 : N/A

 

傳回值 : NSString 目前時間

 

備註 :

 

******************************************************************************/

 

-(NSString *)getDate

 

{

 

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

 

[formatter setDateFormat:@"yyyy-MM-dd EEEE HH:mm:ss a"];

 

NSString *locationString=[formatter stringFromDate: [NSDate date]];

 

[formatter release];

 

return locationString;

 

}




 

複製代碼//大寫的H日期格式將預設為24小時制,小寫的h日期格式將預設為12小時
//不需要特別設置,只需要在dataFormat裡設置類似"yyyy-MMM-dd"這樣的格式就可以了
//日期格式如下:
//y 年 Year 1996; 96
//M 年中的月份 Month July; Jul; 07
//w 年中的周數 Number 27
//W 月份中的周數 Number 2
//D 年中的天數 Number 189
//d 月份中的天數 Number 10
//F 月份中的星期 Number 2
//E 星期中的天數 Text Tuesday; Tue
//a Am/pm 標記 Text PM
//H 一天中的小時數(0-23) Number 0
//k 一天中的小時數(1-24) Number 24
//K am/pm 中的小時數(0-11) Number 0
//h am/pm 中的小時數(1-12) Number 12
//m 小時中的分鐘數 Number 30
//s 分鐘中的秒數 Number 55
//S 毫秒數 Number 978
//z 時區 General time zone Pacific Standard Time; PST; GMT-08:00
//Z 時區 RFC 822 time zone -0800
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()