Quote:
Originally Posted by Natsheh
g_iRoundTime += g_Current_timestamp.......
|
No, that won't work in this case.
Quote:
Originally Posted by Gabe Iggy
Hello.
Sadly, format_time() accepts a unix timestamp as a parameter, while I'm using seconds remaning in g_iRoundTime.
|
The idea was that you would format only the time (and not the date) and I assumed that your values wouldn't ever exceed 24 hours. In that case, it should work just fine. However, I just tested it and I realized that it gets the time/date from your PC which will take into account the timezone. If it used GMT always, it would work just fine.
Now, if you subtract the timezone offset, it works the way I was suggesting. However, subtracting the timezone offset will only work if you are west of the GMT. If you are east of the GMT you'd need to also add 24 hours.
The only other obstacle is accounting for daylights savings which actually shifts your timezone offset.
So, this works for me:
PHP Code:
public cmdTest()
{
new szArg[100], iArg
read_args(szArg, charsmax(szArg))
remove_quotes(szArg)
iArg = str_to_num(szArg)
new iGMTOffset_h = -6 // GMT-06:00
new szTime[100]
format_time(szTime, charsmax(szTime), "%H:%M:%S", iArg - 3600*iGMTOffset_h)
server_print(szTime)
}
However, it's going to be better to write a new function to do this:
PHP Code:
public relative_time_string(szTimeString[], len, iSeconds)
{
formatex(szTimeString, len, "%02d:%02d:%02d", iSeconds / 3600, (iSeconds % 3600) / 60, iSeconds % 60)
}
__________________