• Welcome to Valhalla Legends Archive.
 

How do you add the time? [TT:TT:TTAM]

Started by PsYcHiC, July 01, 2003, 11:44 AM

Previous topic - Next topic

PsYcHiC

How do you make those in front of the text you send? I mean the right time, not the [HH:MM:SS] like [03:23:53 AM]?  Any help would be appreciated.

HH = Hours
MM = Minutes
SS = Seconds

Kp

If you're using C/C++ (which I somewhat doubt), consult strftime documentation.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

c0ol

is this really bot related, i mean seriously this is like simple string manipulation.

iago

char *GetTime(char Buffer[12])
{
   // Get the time:
   long currtime = time(NULL);
   tm *Time = localtime(&currtime);
   sprintf(Buffer, "%02d:%02d:%02d%s", (Time->tm_hour <= 12) ? Time->tm_hour : (Time->tm_hour - 12), Time->tm_min, Time->tm_sec, Time->tm_hour > 12 ? "PM" : "AM");

   return Buffer;
}


That'll return the 12-hour-clock time.  If you want a 24-hours clock, use this:
char *GetTime(char Buffer[10])
{
   // Get the time:
   long currtime = time(NULL);
   tm *Time = localtime(&currtime);
   sprintf(Buffer, "%02d:%02d:%02d",  Time->tm_hour, Time->tm_min, Time->tm_sec);

   return Buffer;
}


And to use these, just use a sprintf to get it into a buffer
char TimeBuf[12];
sprintf("%s <%s> %s\n", GetTime(TimeBuf), sender, message);
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


DarkMinion


void TimeStamp(char *szBuf)
{
   SYSTEMTIME st;
   GetLocalTime(&st);
   sprintf(szBuf, "[%02i:%02i:%02i]  ", st.wHour, st.wMinute, st.wSecond);
}


:P

Yoni


DarkMinion


Lenny

The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

iago

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


UserLoser


Lenny

Would I be correct in saying that I would need a timer to add onto Format(Time, "hh:mm:ss") so it changes?
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Grok

For 24-hour time, use:

Format(Time, "HH:mm:ss")

Lenny

The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Hazard

-1 to Lenny. Stop asking the same question over and over and not reading the answers you get.

!~!HaZaRD!~!

"Courage is being scared to death - but saddling up anyway." --John Wayne

Lenny

I havent been asking the same question...Im asking how would you make a clock not a TIMESTAMP
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.