Hi are we ready for a rant!
Windows has made a new batch window called powershell.
it has trouble formatting utc time.
you can use get-date and try to use .touniversaltime()
touniversaltime() does work but you can't format it.
i e it is short format i e not long form.
this is long format.
Wednesday, January 16, 2013 6:42 AM
write-host -nonewline helps a bit but not ideal.
so we used and ancient borland c compiler to fix the
bloody problem.
touniversaltime is similiar to gmtine in the program
below it tells the time in England.
Also MAKE sure you have set the environmental variable
TZ to your Time zone. i e Control Panel, System
do it before you open dos box i e cmd.exe or powershell.
/* GMT.CPP Wednesday, January 16, 2013 4:44 AM
Author: Herge
Location: Waterloo, Ontario, CANADA */
#include<locale>
#include<conio>
using std::cout;
using std::time_t;
using std::asctime;
using std::gmtime;
using std::localtime;
using std::tm;
using std::strftime;
int main( int )
{
struct tm *toc;
char B [ 128 ];
time_t t;
t = time ( NULL );
toc = gmtime ( &t );
cout << "GMT[UTC] London England Time is: "
<< asctime ( toc );
strftime ( B, sizeof ( B ), " %A,%B,%d,%Y %X %p UTC\n",
gmtime ( &t ) );
cout << B;
getch( );
return 0;
}
The extension MUST be ps1 or it will not go!
## utc.ps1 Wednesday, January 16, 2013 1:45 AM
get-date
$a = get-date
$a.touniversaltime()
write-host -nonewline $a.touniversaltime(),"UTC"
write-host
c:\masm32\bin\gmt.exe
## E N D of File utc.ps1
Your first powershell program output below.
Wednesday, January 16, 2013 6:50:02 AM
Wednesday, January 16, 2013 11:50:02 AM
1/16/2013 11:50:02 AM UTC
GMT[UTC] London England Time is: Wed Jan 16 11:50:02 2013
Wednesday,January,16,2013 11:50:02 AM UTC
you have to press a key to stop it.
Regards herge