Data passed
#1

Hi,

It's possible to check if certain date is passed or no?
Reply
#2

What you mean exactly?
Reply
#3

Explain more with a clear screenshot or more info i dont understand what your trying to say actually btw.
Reply
#4

Like i have date for ex:

2016/09/11 15:30

Now is:

2016/09/10 17:53

How to check if that first date is passed? like i want to make player can write command Up to a certain date
Reply
#5

Ahh okay, you can do this like this:

PHP код:
new d,m,yh,mi,s;
getdate(y,m,d),gettime(h,mi,s);
if(
>= 2016 && >= && >= 11 && >= 15 && mi >= 30)
{
    
//Here its the 11.09.2016 after 15:30
}
else
{
    
//Here its before

Reply
#6

What if i have string where is that data?
Reply
#7

You have to split..that string..

Give an Example string you wanna type in
Reply
#8

new data[ 50 ];
data = "2016/09/11 15:30";
Reply
#9

Dude...thats...a stupid way to store this...
easy would be sth like.."2016/09/11/15/30";

Then just use the split function...and set this in the if condition..
Reply
#10

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
easy would be sth like.."2016/09/11/15/30";
I'd rather have a readable form than this. Not that it is hard to split with ScIrUsna's code:
pawn Код:
sscanf(date_time, "p</>iiip<:>iiI(0)", year, month, day, hour, mins, sec);
Anyway, I think what he actually wants to say is if the datetime specified is in the future. If that is:
pawn Код:
mktime(const mdate_mtime[], utcdiff = 0)
{
    new year, month, day, hour, mins, sec, tyears, tdays, leaps, utc_hrs;
    static const mon_days[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304};
   
    sscanf(mdate_mtime, "p</>iiip<:>iiI(0)", year, month, day, hour, mins, sec);

    month--;
    year -= 1900;
   
    tyears = year - 70;
    leaps = (tyears + 2) / 4;
   
    tdays = mon_days[month];
   
    tdays += day - 1;
    tdays = tdays + (tyears * 365) + leaps;

    utc_hrs = hour + utcdiff;
    return (tdays * 86400) + (utc_hrs * 3600) + (mins * 60) + sec;
}
pawn Код:
if (mktime(datetime_specified_by_user, -GMT) > gettime()) return ...
// ... return error that this date has yet to come
In the UTC difference, add the GMT the server is on but negative.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)