Timestamp... -
Baltimore - 18.01.2015
Hello!
Do you have a
function that converts a
timestamp to a string? (Day, month, year, hour, minute, second)
Thank you.
Re: Timestamp... -
ATGOggy - 18.01.2015
You can make a custom function:
PHP код:
stock TimeStamp()
{
new timestamp[128], day, month, year, hour, minute, second;
getdate(year,month,day);
gettimer(hour,minute,second);
format(timestamp, sizeof(timestamp), "%d:%d:%d, %d:%d:%d", day, month, year, hour, minute, second);
return timestamp;
}
Re : Re: Timestamp... -
Baltimore - 18.01.2015
Quote:
Originally Posted by ATGOggy
You can make a custom function:
PHP код:
stock TimeStamp()
{
new timestamp[128], day, month, year, hour, minute, second;
getdate(year,month,day);
gettimer(hour,minute,second);
format(timestamp, sizeof(timestamp), "%d:%d:%d, %d:%d:%d", day, month, year, hour, minute, second);
return timestamp;
}
|
I want a "dynamic" function, I get the timestamp parameter of the function, and it then leaves me the string as given above (day, month, year, hour, minute, second)
Re: Timestamp... -
xVIP3Rx - 18.01.2015
You already made
this post,
Quote:
Originally Posted by ******
Believe me, it isn't. You need to account for:
Timezones.
Leap years (i.e. leap days).
Leap seconds (of which there is one due soon).
Daylight savings (which can change with no notice).
Formats (dd/mm/yy vs mm/dd/yy etc).
If you want this function, you need to be VASTLY more precise about exactly what you want, because there is no single representation of time.
|
Re: Timestamp... -
RedFusion - 18.01.2015
pawn Код:
timestamp(&year, &month, &day, &hour, &minute, &second)
{
new
string[20]
;
getdate(year, month, day);
gettime(hour, minute, second);
format(string, sizeof string, "%i-%02i-%02i %02i:%02i:%02i",
year, month, day, hour, minute, second
);
return string;
}
Re : Re: Timestamp... -
Baltimore - 18.01.2015
Quote:
Originally Posted by RedFusion
pawn Код:
timestamp(&year, &month, &day, &hour, &minute, &second) { new timestamp[20] ;
getdate(year, month, day); gettime(hour, minute, second);
format(timestamp, sizeof timestamp, "%i-%02i-%02i %02i:%02i:%02i", year, month, day, hour, minute, second );
return timestamp; }
|
I want to get the timestamp parameter of the function, there is time and everything directly ...
Re: Timestamp... -
RedFusion - 18.01.2015
pawn Код:
timestamp(&year, &month, &day, &hour, &minute, &second, string[], string_size = sizeof string)
{
getdate(year, month, day);
gettime(hour, minute, second);
format(string, string_size, "%i-%02i-%02i %02i:%02i:%02i",
year, month, day, hour, minute, second
);
}
Re : Re: Timestamp... -
Baltimore - 18.01.2015
Quote:
Originally Posted by RedFusion
pawn Код:
timestamp(&year, &month, &day, &hour, &minute, &second, string[], string_size = sizeof string) { getdate(year, month, day); gettime(hour, minute, second);
format(string, string_size, "%i-%02i-%02i %02i:%02i:%02i", year, month, day, hour, minute, second ); }
|
Exemple for use this code please...
I have only the timestamp, so I do not see how I could fill the parameters hours, day.. To the function
Re: Timestamp... -
tyler12 - 18.01.2015
https://sampforum.blast.hk/showthread.php?tid=347605
Re: Timestamp... -
RedFusion - 18.01.2015
Example Usage:
pawn Код:
public OnFilterScriptInit()
{
new
year,
month,
day,
hour,
minute,
second,
string[20]
;
timestamp(year, month, day, hour, minute, second, string);
printf("Timestamp: %s", string);
printf("Year: %i", year);
printf("Month: %i", month);
printf("Day: %i", day);
printf("Hour: %i", hour);
printf("Minute: %i", minute);
printf("Second: %i", second);
}