[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]

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
I am not out to post "Copy and Paste" code. Figure it out yourselfIF YOU ARE GOING TO USE IN YOUR HACK, REMEMBER TO GIVE ME CREDITS
Remember to Thank Me!
Remember to Thank Me!

