關於時間的一些轉化

2021-08-03 08:29:33 字數 2426 閱讀 8733

#define field_base_second_ago                           @

"%d秒前"

#define field_base_minute_ago                           @

"%d分鐘前"

#define field_base_hour_ago                             @

"%d小時前"

#define field_base_day_ago                              @

"%d天前"

#define field_base_month_ago                            @

"%d月前"

#define field_base_year_ago                             @

"%d年前"

#define differtime                 30*

60//單位:

秒 @implementation

timeutil //

根據返回距離當前時間多長時間

+ (nsstring

*)calutedatebycurrentdate:(

nsdate

*)date

else

} else

else

if(component.

month!=0

) else

if(component.

day!=0)

else

if(component.

hour!=0

) else

if(component.

minute!=0

) else

if(component.

second!=0

) else

} return

timestr; }

//時分秒相互轉換

+ (nsdictionary

*)convertsecond2hourminutesecond:(

int)second

/** *

根據時間字串返回總時長

,傳入引數格式必須為

"00:00:00"樣式

*/ + (double

)getvideoalltimewithtimestring:(

nsstring

*)timestring if

([timestring

isequaltostring

:@""

])

nsarray

*arr = [timestring

componentsseparatedbystring

:@":"];

if(arr ==

nil) if

(arr.

count

<1)

double

alltime =

0.0f;

for(

inti =

0; i < arr.

count

; i++)

return

alltime; }

/** *

根據時間總時長返回時間字串

,返回的字串為

"00:00:00"樣式

*/ + (nsstring

*)getvideoalltimestringwithvideoalltime:(

double

)videoduration orvideoalltimestring:(

nsstring

*)timestring

else

if(timestring)

double

alltime = [

self

getvideoalltimewithtimestring

:timestring];

long

hour = alltime /

3600;

long

minite = (alltime - hour *

3600

) /60;

long

miao = alltime - hour *

3600

- minite *60;

return

[nsstring

stringwithformat

:@"%02d:%02d:%02d"

,(int

)hour,(

int)minite,(

int)miao]; }

return

nil; }

關於時間的一些理解

utc時間 和本地時間 世界的每個地區都有自己的本地時間,在internet 及無線電通訊時,時間的統一非常重要!整個地球分為二十四時區,每個時區都有自己的本地時間。在國際無線電通訊中,為統一而普遍使用乙個標準時間,稱為通用協調時 utc,universal time coordinated utc...

關於獲取時間的一些操作

js獲取當前日期時間及其它操作 var today new date var year today.getyear 獲取當前年份 2位 var year today.getfullyear 獲取當前完整的年份 4位,1970 var month dataprocess today.getmonth ...

關於時間管理的一些技巧

前言 你是否有這種體會 坐在電腦面前忙碌了一天,等到快下班的時候發現另一大堆的事情沒有做完。假設這種情況多次發生,我認為你是時候對你的時間好好管理一下了。輕重緩急 19世紀義大利經濟學家帕累託提出 生活中80 的結果差點兒源於20 的活動。比方 20 的客戶給你帶來80 的業績。世界上80 的財富被...