Convert miliseconds to regular time?
#5

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);
Reply


Messages In This Thread
Convert miliseconds to regular time? - by sciman001 - 04.05.2011, 22:34
Re: Convert miliseconds to regular time? - by Steven82 - 04.05.2011, 22:45
Re: Convert miliseconds to regular time? - by sciman001 - 04.05.2011, 22:55
Re: Convert miliseconds to regular time? - by MadeMan - 04.05.2011, 23:02
Re: Convert miliseconds to regular time? - by BigETI - 04.05.2011, 23:26

Forum Jump:


Users browsing this thread: 3 Guest(s)