[RELEASE] Time & Date Function

Posts 115 of 27 · Page 1 of 2
[RELEASE] Time & Date Function
Hi All! I am new to MPGH. I'll throw u guys some functions

Includes:
[php]#include <time.h>[/php]

Time:
[php]/*****************The Time*******************/
char *TheTime()
{
char *logbuf = new char[ 256 ];
struct tm *newtime;
char am_pm[] = "AM";
time_t long_time;
time( &long_time );
newtime = localtime( &long_time );
if( newtime->tm_hour > 12 )
strcpy( am_pm, "PM" );
if( newtime->tm_hour > 12 )
newtime->tm_hour -= 12;
if( newtime->tm_hour == 0 )
newtime->tm_hour = 12;
sprintf( logbuf, "[ %02d:%02d:%02d %s ]", newtime->tm_hour, newtime->tm_min, newtime->tm_sec, am_pm );
return logbuf;
}
/*****************The Time*******************/[/php]

Date:
[php]/*****************The Date*******************/
char *TheDate()
{
time_t curtime = time(0);
tm now=*localtime(&curtime);
char dest[BUFSIZ]={0};
const char format[]="[ %d:%b:%Y ]";
if (strftime(dest, sizeof(dest)-1, format, &now)>0)
return dest;
}

/*****************The Date*******************/[/php]


If you have any C++ Common sense, you'd know how to draw it I am not out to post "Copy and Paste" code. Figure it out yourself


IF YOU ARE GOING TO USE IN YOUR HACK, REMEMBER TO GIVE ME CREDITS

Remember to Thank Me!
It works. i just added it and compiled and got it to work.

thanks bro
Nice Release
This Works.
Thank you Guys!
Nice Job Unknown and welcome.
Don't say it, press it!
This also works :
Code:
SYSTEMTIME st;

GetSystemTime(&st);

st.w(insert time measurement here)
For example :

Code:
char timebuffer[512];

sprintf_s(timebuffer, 512, "[ %d / %d / %d ] - [ %d : %d : %d ]", (int)st.wMonth, (int)st.wDay, (int)st.wYear, (int)st.wHour - 4, (int)st.wMinute, (int)st.wSecond);

DrawString(10, 10, timebuffer, D3DCOLOR_XRGB(255, 0, 0));
Right now it would output this :
[ 07 / 12 / 2010 ] - [ 3 : 22 : 18 ]

At least where I live.
Quote Originally Posted by Crash View Post
This also works :
Code:
SYSTEMTIME st;

GetSystemTime(&st);

st.w(insert time measurement here)
For example :

Code:
char timebuffer[512];

sprintf_s(timebuffer, 512, "[ %d / %d / %d ] - [ %d : %d : %d ]", (int)st.wMonth, (int)st.wDay, (int)st.wYear, (int)st.wHour - 4, (int)st.wMinute, (int)st.wSecond);

DrawString(10, 10, timebuffer, D3DCOLOR_XRGB(255, 0, 0));
Right now it would output this :
[ 07 / 12 / 2010 ] - [ 3 : 22 : 18 ]

At least where I live.
Shouldn't you use GetLocalTime instead?
they both work. seals is a alittle easier for a noob to understand
It works either way, thats just my method.
Quote Originally Posted by Fabolous View Post
It works either way, thats just my method.
If you wouldn't mind putting it up there with yours that would be nice.

@whatup777 : If they don't set their computer's clock to the right time they're retarded.
can you put one for C# and VB? i am going to try something with this later
Lol. You can do that yourself. Copy the code. Like you were going to anyways. Except instead of copying and pasting into C++. Go to google, and find a C++/C# Code Converter, and place it in there to convert it into a C# Code.
those converters are so expensive though
Posts 115 of 27 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?