Getting the date
#1

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?
Reply
#2

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

Doesnt really help with the adding a week onto it part
Reply
#4

How to: Unix timestamps

May be Above Thread Will Guide You...
Reply
#5

I have already tried that. I didn't get very far.
Reply
#6

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;
}
Reply
#7

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
Reply
#8

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
Reply
#9

That is the one I am using now, which says its the 26th when infact its the 24th
Reply


Forum Jump:


Users browsing this thread: