SA-MP Forums Archive
A real problem - Date to Timestamp - help - 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: A real problem - Date to Timestamp - help (/showthread.php?tid=662231)



A real problem - Date to Timestamp - help - None1337 - 26.12.2018

So, i have a last login on a player saved like this:

2018-12-26 19:42:18

How can I get the exact timestamp on this date?

I have already timestampdate.inc but the format should be like: 26.12.2018 (probably in your country: 12.26.2018 ), and i can't specify the hours, minutes and seconds.

Does anybody know a function that i convert the date above (2018-12-26 19:42:18 ) to unixtime?

I really need this.

Thanks!


Re: A real problem - Date to Timestamp - help - N3mesiS - 26.12.2018

Perhaps, getdate and gettime?

PHP код:
new dmygetdate(ymd);
new 
hmnsgettime(hmns); 



Re: A real problem - Date to Timestamp - help - None1337 - 26.12.2018

No, I already have the date: 2018-12-26 19:42:18 but I want to be in timestamp,
like: 1545846977 (2018-12-26T17:56:17+00:00) - source: wikipedia.


Re: A real problem - Date to Timestamp - help - NaS - 26.12.2018

So you technically only need to extract the day, month, year and hour, minute and second to pass it to a function from the include, right? There should be DateToTimestamp which takes the date as seperate values.

You could use sscanf for it, if the format is always going to be the same.

PHP код:
new daymonthyearhourminutesecond;
sscanf(date_string"p<-:>iiiiii"yearmonthdayhourminutesecond); 



Re: A real problem - Date to Timestamp - help - aKnoxx - 26.12.2018

PHP код:
new    Timestamp gettime(HourMinuteSecond); 
This?

Outputs like this: 1545848117