AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   convert DATE (https://forums.alliedmods.net/showthread.php?t=156351)

^SmileY 05-04-2011 23:29

convert DATE
 
i would by convert this date:

PHP Code:

02.05.2011    >>>    2.5.2011 

(Remove 0, of the day and month)

PHP Code:

new DATE[13];
new 
DAY[03],MONTH[03],YEAR[5];

    
get_time("%d",DAY,charsmax(DAY));
    
get_time("%m",MONTH,charsmax(MONTH));
    
get_time("%Y",YEAR,charsmax(YEAR))

    
replace_all(DAY,1,"0","")
    
replace_all(MONTH,1,"0","")

    
formatex(DATE,charsmax(DATE),"%s.%s.%s",DAY,MONTH,YEAR)
    
    
client_print(id,3,"[LOL] DATE: %s",DATE

This is Correct? Any bug? suggestions ?

Thanks

fysiks 05-04-2011 23:54

Re: convert DATE
 
Off the top of my head:

PHP Code:

formatex(DATE,charsmax(DATE),"%d.%d.%s",str_to_num(DAY),str_to_num(MONTH),YEAR


^SmileY 05-05-2011 00:00

Re: convert DATE
 
I will testing (Tks)

fysiks 05-05-2011 00:00

Re: convert DATE
 
Oh, and if doing my way, you should remove the replace_all() functions (as my solution is an alternative to using replace_all).

ConnorMcLeod 05-05-2011 01:46

Re: convert DATE
 
PHP Code:

    new DATE[11]
    
get_time("%d.%m.%Y"DATEcharsmax(DATE))
    if( 
DATE[3] == '0' )
    {
        
replace(DATE[3],charsmax(DATE)-3"0""")
    }
    
client_print(idprint_chat"[LOL] DATE: %s"DATE[0] == '0' DATE[1] : DATE



All times are GMT -4. The time now is 04:28.

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