Posts: 2,431
Threads: 86
Joined: Nov 2009
Reputation:
0
There are already functions for that...use the wiki.
gettime
getdate
Posts: 1,046
Threads: 29
Joined: Mar 2010
pawn Код:
stock GetDateAndTimeOfMs(millisecond, &year, &month, &day, &hour, &minute, &second)
{
new accuracity;
tickcount(accuracity);
while(millisecond > accuracity-1)
{
millisecond = millisecond-accuracity;
second++;
}
while(second > 59)
{
second = second-60;
minute++;
}
while(minute > 59)
{
minute = minute-60;
hour++;
}
while(hour > 23)
{
hour = hour-24;
day++;
}
while(day > 27)
{
day = day-28;
month++;
}
while(month > 11)
{
month = month-12;
year++;
}
}
Usage:
pawn Код:
GetDateAndTimeOfMs(milliseconds, &year, &month, &day, &hour, &minute, &second);
Example:
pawn Код:
new year, month, day, hour, minute, second;
GetDateAndTimeOfMs(1000000000, year, month, day, hour, minute, second);
printf("Time: %d years | %d months | %d days | %d hours | %d minutes | %d seconds", year, month, day, hour, minute, second);