Posted by: Preetam | March 28, 2007

WorldClock with PowerShell

As far I know, we don’t keep looking at all clocks on our desktop, we only view when we need them, so then why keep some 3rd application running in the background when powershell is there. I found simple way. My work responsibility is spread across countries, I selected the one below.


Write-Host “Dallas =>” `t $CurDate.addhours(-13) -foreground “yellow”
Write-Host “NYC =>” `t `t $CurDate.addhours(-12) -foreground “Green”
Write-Host “Santa Clara =>” `t $CurDate.addhours(-15) -foreground “RED”
Write-Host “My India =>” `t $CurDate.addhours(-2.5) -foreground “White”
Write-Host “London =>” `t $CurDate.addhours(-7) -foreground “DarkGreen” -background “white”

Now code is getting the current date, then subtracting them from my current timezone, which in Singapore as of now. Once you have this information, subtract them from current date, thats it. Nothing more, nothing less. Do some formatting and see the output. With respect to Singapore these are current time across the world


But this as simple and this is just part of it, most of the time I get calls across the country and they would naturally mentioned time of their country and ask me do things in EST,GMT, My Mind gets always confuse in calculating timezone difference. I found simple trick.


$Country=read-host “City please(Lon,NYC)”

switch($country) {

“Lon” {

$WhatTime=read-host “London time Please “
Write-host “SNG Equiv[LON] TIME ” $Result -foreground “DarkGreen” -background “white”

“NYC” {

$WhatTime=read-host “New York time Please “
Write-host “SNG Equiv[NYC] TIME” $Result -foreground “DarkGreen” -background “white”

What I’m doing here, I’m asking which city, if he says Lon, I ask him what time, he mentions time and I get equivalent Singapaore time.

For example someone calls and asks me set something to execute at 1800 hrs GMT, so that means for me in Singapore equivalent, see the result

With date function you can do n number of things, I have made life easy for me and for my customers, How about you ? 



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: