Raised This Month: $ Target: $400
 0% 

[SOLVED] Add X days in a date


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-07-2016 , 15:50   Re: Add X days in a date
Reply With Quote #5

Bugsy, AMXX has natives for dealing with that, you don't need custom include.

PHP Code:
AddToDate(const OriginalDate[], const DaysToAddFinalDate[], const Size)
{
    new const 
FormatRule[] = "%d.%m.%Y"
    
new const SecondsInDay 86400
    
    
new CurrentTimeStamp parse_time(OriginalDateFormatRule)
    
CurrentTimeStamp CurrentTimeStamp DaysToAdd SecondsInDay
    format_time
(FinalDateSizeFormatRuleCurrentTimeStamp)

You can use something like this, should be better. d is day, m is month, Y is year. You can also change the format of date, use / instead of . or make it m/d/y instead of d/m/y.

An example:
PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_srvcmd("output_date""ServerCommand_OutputDate")
}

public 
ServerCommand_OutputDate()
{
    new 
CurrentDate[11], FinalDate[11]
    
get_time("%d.%m.%Y"CurrentDatecharsmax(CurrentDate))
    
AddToDate(CurrentDate5FinalDatecharsmax(FinalDate))
    
    
server_print("CurrentDate: %s | NewDate: %s"CurrentDateFinalDate)
}

AddToDate(const OriginalDate[], const DaysToAddFinalDate[], const Size)
{
    new const 
FormatRule[] = "%d.%m.%Y"
    
new const SecondsInDay 86400
    
    
new CurrentTimeStamp parse_time(OriginalDateFormatRule)
    
CurrentTimeStamp CurrentTimeStamp DaysToAdd SecondsInDay
    format_time
(FinalDateSizeFormatRuleCurrentTimeStamp)

__________________

Last edited by HamletEagle; 05-07-2016 at 16:58.
HamletEagle is offline
 



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 18:38.


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