format sec
#1

formatsec dont work it givs me wrong answer

only the "days" works
pawn Код:
stock formatsec(secounds, &days, &months, &years)
{
    days = secounds/3600/24;
    months = secounds/5200/30;
    years = secounds/360;
}
Reply
#2

It's not that easy to make as months may have 28, 29, 30 or 31 days and years may have 365 or 366 days.
Reply
#3

Make it a float, You'll be having a decimal number if so you're using all of the parameters stated.

pawn Код:
stock formatsec(secounds, &Float:days, &Float:months, &Float:years)
{
    days = secounds/3600/24;
    months = secounds/5200/30;
    years = secounds/360;
}
( 10 [SECONDS] ) / 5200 / 30 = 6.41025641025641e-5
Reply
#4

Ok, do you have amother sug how to do it, im trying to format from timestam to days, months, years..
Reply
#5

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
Ok, do you have amother sug how to do it, im trying to format from timestam to days, months, years..
Why you need it? You can use getdate function.

https://sampwiki.blast.hk/wiki/Getdate
Reply
#6

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Why you need it? You can use getdate function.

https://sampwiki.blast.hk/wiki/Getdate
to tell the person when he will be unbanned

i did like this to find the days, and it works, but idk how to get months and years working

days = gettime() - timestamp/3600/24;
Reply
#7

Is this what you're looking for? http://forum.sa-mp.com/showthread.ph...ime#post939475
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
dont that make the timestamp?

i did somethinglike this now, but i dont get the rest

pawn Код:
stock tstodate(timestamp)
{
    new string[128];
    format(string, sizeof(string), "SELECT FROM_UNIXTIME(%d, '%Y %D %M')", timestamp);
    mysql_query(string);
}
Reply
#9

Click here!
You should be able to use that instead, it works fine.
Reply
#10

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
dont that make the timestamp?
The date() function is what you need.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)