Getting the date - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Getting the date (
/showthread.php?tid=380076)
Getting the date -
iTorran - 24.09.2012
I need to get the current date, and then add a week onto it..
Does anyone know any simple ways I could go about doing this?
Or as simple as possible atleast.. for example if the current date is
24/09/2012
I would want to get the date a week from then.. so 01/10/2012.
So yeah, does anyone know how I might go ahead doing this?
Re: Getting the date -
Danyal - 24.09.2012
May be this will help...
pawn Код:
new Year, Month, Day;
getdate(Year, Month, Day);
printf("%02d/%02d/%d", Day, Month, Year);
new Days = getdate();
printf("Days since the start of the year: %d", Days);
Re: Getting the date -
iTorran - 24.09.2012
Doesnt really help with the adding a week onto it part
Re: Getting the date -
Danyal - 24.09.2012
How to: Unix timestamps
May be Above Thread Will Guide You...
Re: Getting the date -
iTorran - 24.09.2012
I have already tried that. I didn't get very far.
Re: Getting the date -
ReneG - 24.09.2012
I have no clue on how to do it in dd/mm/yyyy format since not every month has the same amount of days, but this can easily be done with gettime()
For example
pawn Код:
new gTime[MAX_PLAYERS];
CMD:addweek(playerid, params[])
{
// gettime() will return the time in seconds
gTime[playerid] = gettime() + 604800; // 604800 seconds is one week
return 1;
}
CMD:check(playerid, params[])
{
if(gTime[playerid] < gettime()) {
SendClientMessage(playerid, -1, "It has been one week!");
}
else {
SendClientMessage(playerid, -1, "It hasn't been one week!");
}
return 1;
}
Re: Getting the date -
iTorran - 24.09.2012
I got it now thanks.
I read past something before, but got it now.
Does anyone know any functions or anything to convert timestamps into dates (DD/MM/YY HH/MM/SS)?
I found one function but its off by 2 days
Re: Getting the date -
Danyal - 24.09.2012
TimestampToDate
Have a look i cant provide stuff becoz i dont know much about it i can only suggest you
Specified Thread consulting your problem
Re: Getting the date -
iTorran - 24.09.2012
That is the one I am using now, which says its the 26th when infact its the 24th