open.mp forum
[Pawn] Add days to current time - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] Add days to current time (/showthread.php?tid=2264)



Add days to current time - Torque - 2021-12-28

I'm saving the last login date/time using Now() in MySQL which sets a string such as?2021-12-28 12:41:53



I want to check if 30 days have passed since the last login. How can I do this in the script? I imagine I would have to use a different method of saving the date in order to check this.


RE: Add days to current time - Radical - 2022-01-02

Use unix time.



PHP Code:
// On player logged-in format(query, sizeof query, "UPDATE `users` SET `last_login` = %i WHERE `id` = %i", gettime(), id); // Check?player last login cache_get_value_name_int(0, "last_login", value); if(gettime()-value > 60*60*24*30) { ? ? // 30 days passed from last login }



RE: Add days to current time - Y_Less - 2022-03-25

Don't use formatted dates ever. Just save your data using unix timestamps. They make everything with time way way easier.