Raised This Month: $ Target: $400
 0% 

Solved Precise calculation between 2 dates and times in UnixTimestamp


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-23-2021 , 21:28   Re: Precise calculation between 2 dates and times in UnixTimestamp
Reply With Quote #10

Ok, it's a lot simpler then if I understand correctly. format_time() can do most of the work for you, see http://cplusplus.com/reference/ctime/strftime/

PHP Code:

#include <amxmodx>

enum _:WeekDays
{
    
wdSunday,
    
wdMonday,
    
wdTuesday,
    
wdWednesday,
    
wdThursday,
    
wdFriday,
    
wdSaturday
}

enum _:TimeStringPos
{
    
tspDayOfWeek,
    
tspSpace,
    
tspHour
}

public 
plugin_init() 
{
    new 
szOutput] , iDayOfWeek iHour;

    
//1624465533 = Wed Jun 23 2021 12:25:33 GMT-0400 (Eastern Daylight Time)
    
format_timeszOutput charsmaxszOutput ) , "%w %H" 1624465533 );
    
    
szOutputtspSpace ] = EOS;
    
iDayOfWeek str_to_numszOutputtspDayOfWeek ] );
    
iHour str_to_numszOutputtspHour ] );
    
    if ( ( 
iDayOfWeek == wdWednesday ) && ( iHour == 12 ) )
    {
        
server_print"It is Wednesday at 12pm" );
    }

__________________

Last edited by Bugsy; 06-23-2021 at 21:29.
Bugsy 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 02:33.


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