saving register date
#1

Hi,

I'd like to know how can I save the date when the player registered so I can show it in /stats for example:

Registered Date: dd/mm/yyyy (2/10/2014)

Note: I'm using MySQL

Thanks!
Reply
#2

Use gettime() and save that value then format later.
Reply
#3

Eh ya Maro 3aml eh
Kol Sana We Anta Tayeb
Reply
#4

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use gettime() and save that value then format later.
Thanks,

I used getdate instead and it worked like a charm!
Reply
#5

Oh, It is not working, sorry.

It is showing

What I did:

I added RegDate[16] in the enum of Player data, And in registering I added:
pawn Код:
new Date[16], year, month, day;
            getdate(year, month, day);
            format(Date, sizeof(Date), "%d/%d/%d", day, month, year);
And, I Inserted it when registering with the '%s' and at the end of the format, I wrote pInfo[playerid][RegDate] And after inserting I added
pawn Код:
pInfo[playerid][RegDate] = Date;
I did the same in loading the accounts ..

I thought it is working since I added a testing command
pawn Код:
CMD:regdate( playerid, params [] )
{
    format(mstring, sizeof(mstring), "Register date: %s", pInfo[playerid][RegDate] );
    SendClientMessage( playerid, -1, mstring);
    return 1;
}
And, It was sending me a message:
Register date: 02/10/2014
Reply
#6

Use getttime() it will return a unix timestamp which is easy to work with in any way you could possibly use it!
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use gettime() and save that value then format later.
Quote:
Originally Posted by Pottus
Посмотреть сообщение
Use getttime() it will return a unix timestamp which is easy to work with in any way you could possibly use it!
What I understood from the wiki of gettime that its used in hours, minutes, seconds, I need to use it in date, thats why I used getdate
Reply
#8

Well

I'm not good with MySQL but open the table and make the type (Date, Datetime or Timestamp)

P.s: Pm me
Reply
#9

Quote:
Originally Posted by ShadyX
Посмотреть сообщение
Well

I'm not good with MySQL but open the table and make the type (Date, Datetime or Timestamp)

P.s: Pm me
Lol, The screenshoot already shows that I setted the type to "date"

I am not PMing you, If you would like to help, help here so all of the members know how.
Reply
#10

No, it should be an integer if using Unix timestamps. A timestamp saves the number of seconds passed since 1/1/1970. Something like 1.4 billion currently. That value can be converted back into a date and time. Most easily done with the FROM_UNIXTIME MySQL function, but there are Pawn implementations as well (although slower).

PHP код:
SELECT FROM_UNIXTIME(1412285145'%M %D %Y, at %H:%i'
Код:
October 2nd 2014, at 23:25
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)