Raised This Month: $51 Target: $400
 12% 

Formattime error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-04-2012 , 14:39   Formattime error
Reply With Quote #1

Well, im trying to compare a date in my database against the current date. But when i do that it only said to run code even if it isnt same date as in database, so when the current date is past the date in database i want to run this but it only runs whole time xD?

PHP Code:
decl String:expire[255];
            
SQL_FetchString(hndl3expiresizeof(expire));
            
new 
tima StringToInt(expire);
decl String:idag[100];
FormatTime(idagsizeof(idag), "%d/%m/%Y"GetTime());
new 
time StringToInt(idag);
            
if (
tima <= time)
{
    
//do something

any suggestions?
__________________

Last edited by ecca; 01-04-2012 at 14:41.
ecca is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 01-04-2012 , 15:32   Re: Formattime error
Reply With Quote #2

An example of what FormatTime would give you today, "04/01/2012"
You see that? StringToInt doesn't recognize division, and I'm pretty sure you don't want that to be divided. StringToInt would error and give you 0 for time. It's probably safe to store times as timestamps instead.

Edit: Why are you supplying FormatTime with the current timestamp? It already gives you the current date if the stamp parameter is left empty.
__________________

Last edited by McFlurry; 01-04-2012 at 15:36.
McFlurry is offline
Send a message via Skype™ to McFlurry
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-04-2012 , 15:35   Re: Formattime error
Reply With Quote #3

Can you give me an example how i can check instead with timestamps

The date today is 04/01/2012 and in the db its 04/03/2012
__________________
ecca is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 01-04-2012 , 15:37   Re: Formattime error
Reply With Quote #4

Generate a timestamp for that date here. Then simply retrieve the timestamp from the database as an int and compare it to GetTime()'s return value.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-04-2012 , 15:43   Re: Formattime error
Reply With Quote #5

But its diffrent dates, in database, some players got 04/06/2012 and so on
__________________
ecca is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 01-04-2012 , 16:20   Re: Formattime error
Reply With Quote #6

The timestamp is just a number of seconds that have passed since the UNIX epoch. You can do 60*60*24 and it to a timestamp to add a full day, and vice versa with subtraction. You'll have to modify the expiration dates for your players from now on.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-04-2012 , 16:27   Re: Formattime error
Reply With Quote #7

Isnt there any other way, im pretty sure it can work with formattime
__________________
ecca is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 01-04-2012 , 16:30   Re: Formattime error
Reply With Quote #8

Use timestamps, they're universal.

http://www.unixtimestamp.com/index.php
__________________

Last edited by thetwistedpanda; 01-04-2012 at 16:30.
thetwistedpanda is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-04-2012 , 16:38   Re: Formattime error
Reply With Quote #9

I dont get the timestamp, i really want to use realdate
__________________
ecca is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 01-04-2012 , 16:40   Re: Formattime error
Reply With Quote #10

What isn't there to get, the timestamp is just the number of seconds that have passed since the UNIX epoch (January 1, 1970 00:00:00 UTC).
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode