mysql timestamps
#1

stock date return 0 and timestamp return 0, why?
pawn Код:
stock date(days, months, years)
{
    new string[128], timestamp, hours, minutes, seconds;
    gettime(hours, minutes, seconds);
    format(string, sizeof(string), "SELECT UNIX_TIMESTAMP('%d-%02d-%02d %02d:%02d:%02d')", years, months, days, hours, minutes, seconds);
    mysql_query(string);
    mysql_store_result();

    timestamp = mysql_fetch_int();
    mysql_free_result();
    return timestamp;
}

stock timestamp(timestamp) //not finished
{
    new string[128];
    format(string, sizeof(string), "SELECT FROM_UNIXTIME(%d, '%Y %D %M')", timestamp);
    mysql_query(string);
}
Reply
#2

timestamp(timestamp) has no return value

timestamp = mysql_fetch_int(); ..?

'%d-%02d-%02d %02d:%02d:%02d' is a string.
Reply
#3

Why don't you just use gettime without any arguments? It returns a timestamp.

https://sampwiki.blast.hk/wiki/Gettime
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Why don't you just use gettime without any arguments? It returns a timestamp.

https://sampwiki.blast.hk/wiki/Gettime
it return the current timestamp rite?
i want to make an temp ban script so i can create the timestamp for 2 days/months/years in future

so i can use "stock timestamp" to tell "You will be unbanned at this time: %d-%02d-%02d %02d:%02d:%02d"
Reply
#5

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
it return the current timestamp rite?
i want to make an temp ban script so i can create the timestamp for 2 days/months/years in future

so i can use "stock timestamp" to tell "You will be unbanned at this time: %d-%02d-%02d %02d:%02d:%02d"
Yep, it returns the timestamp of 0 GMT since the date of 01 January 1970, and time of 00:00 AM. I also made my temporally ban/mute system with timestamps. But guess what the best part is, it works perfectly. (In my opinion)
Reply
#6

Quote:
Originally Posted by Improvement™
Посмотреть сообщение
Yep, it returns the timestamp of 0 GMT since the date of 01 January 1970, and time of 00:00 AM. I also made my temporally ban/mute system with timestamps. But guess what the best part is, it works perfectly. (In my opinion)
ok, so you made a temp ban/mute system, what does that help me? i dont see any of your posts that you have realeased it so idk who you did it
Reply
#7

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
ok, so you made a temp ban/mute system, what does that help me? i dont see any of your posts that you have realeased it so idk who you did it
I was just answering and explaining your question, and also mentioning that I use the timestamp methode for temporally systems. And if you expect me to post any kind of systems on this topic, then the answer is obviously No.

Kind Regards,
Improvement™
Reply
#8

ok... anyone else know how to make a function to create timestamps by typing the date, month, year?

and a function to format the timestamp to date: day, month, year - hour, minute, second
Reply
#9

It doesn't work 100% most probably because, re-read the Quote once more :P.

Quote:
Originally Posted by Improvement™
Посмотреть сообщение
Yep, it returns the timestamp since the date of 01 January 1970, and time of 00:00 AM (0 GMT). I also made my temporally ban/mute system with timestamps. But guess what the best part is, it works perfectly. (In my opinion)

FIRST EDIT:
pawn Код:
new timestamp = gettime(); //example timestamp of 0 GMT
new timestamp = gettime()+3600; //example timestamp of 1 GMT (+3600 = +1 Hour)
new timestamp = gettime()+7200; //example timestamp of 2 GMT (+7200 = +2 Hours)
new timestamp = gettime()+10800; //example timestamp of 3 GMT (+10800 = +3 Hours)
//Etc. Untill you get your local timestamp.
Reply
#10

Quote:
Originally Posted by Improvement™
Посмотреть сообщение
It doesn't work 100% most probably because, re-read the Quote once more :P.





FIRST EDIT:
pawn Код:
new timestamp = gettime(); //example timestamp of 0 GMT
new timestamp = gettime()+3600; //example timestamp of 1 GMT (+3600 = +1 Hour)
new timestamp = gettime()+7200; //example timestamp of 2 GMT (+7200 = +2 Hours)
new timestamp = gettime()+10800; //example timestamp of 3 GMT (+10800 = +3 Hours)
//Etc. Untill you get your local timestamp.
Thnaks is there a way with pawno to find somones GMT time?
like:

Get_GMT_Time(playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)