Hi C++ fans!
// GMT.cpp : Defines the entry point for the console application.
// Friday, January 18, 2013 3:55 PM
#include "stdafx.h"
// crt_gmtime.c
// compile with: /W3
// This program uses _gmtime64 to convert a long-
// integer representation of coordinated universal time
// to a structure named newtime, then uses asctime to
// convert this structure to an output string.
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
struct tm *newtime;
struct tm today;
__int64 ltime;
char buff[128];
errno_t err;
_time64( <ime );
// Obtain coordinated universal time:
newtime = _gmtime64( <ime ); // C4996
// Note: _gmtime64 is deprecated; consider using _gmtime64_s
asctime_s( buff, sizeof(buff), newtime );
int i;
for ( i = 0; i < sizeof(buff); i++ )
{ // Remove line Feed with Space
if( buff [ i ] == 10 ) buff [ i ] = 32;
}
cout << "Coordinated universal time is "
<< buff << "UTC"
<< endl;
// Use time structure to build a customized time string.
err = _localtime64_s( &today, <ime );
if (err)
{
cout << " _localtime64_s failed due to Bad arguments.";
exit(1);
}
strftime( buff, 128,
"Today is %A, day %d of %B in the year %Y.\n", &today );
cout << buff;
strftime( buff, sizeof(buff),"%#c %p %z", &today );
cout << buff << endl;
_getch(); // Wait!
return 0;
}
/* expected output
Coordinated universal time is Fri Jan 18 22:00:58 2013 UTC
Today is Friday, day 18 of January in the year 2013.
Friday, January 18, 2013 17:00:58 PM EST
*/
I have Windows XP SP3
Regards Herge