26.04.2015, 20:52
There are many ways to do this, i also suggest not sending the hours/mins because they usually differ to players. So sending DD/MM/YYYY is fine.
Код:
//Off the internet, no credits found GetDateStamp(Time = 0, bool:IsUnixTime = true) { new hour, minute, sec; gettime(hour,minute,sec); new secs; secs = Time; if (IsUnixTime) secs -= gettime(); secs += sec; new mins; if (secs >= 60) { mins = secs / 60; secs -= mins * 60; } mins += minute; new hours; if (mins >= 60) { hours = mins / 60; mins -= hours * 60; } hours += hour; new Days; if (hours >= 24) { Days = hours / 24; hours -= Days * 24; } new MonthDays[] = {31,28,31,30,31,30,31,31,30,31,30,31}; new Year; new Month; new Day; getdate(Year,Month,Day); if ((Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) MonthDays[1] = 29; Days += Day; new Months; while (Days > MonthDays[Month - 1]) { Days -= MonthDays[Month - 1]; Months++; } Months += Month; new Years; if (Months > 12) { Years = Months / 12; Months -= Years * 12; } Years += Year; new YearDay; new YearDays[] = {0,31,59,90,120,151,181,212,243,273,304,334}; YearDay = Days + YearDays[Months - 1]; if (Months > 2 && (Year % 4 == 0) && (Year % 100 != 0) || (Year % 400 == 0)) YearDay++; new string[64]; format(string,sizeof (string),"%i-%02i-%i",Days,Months,Years); return string; }