Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Time from Certain Timezone
#1
Since I work with folks in India, I need to do I little Onscreen Display of the current time in India.

Is there a way to do this?
An old blog on QM coding and automation.

The Macro Hook
#2
It's easier in QM3. Or use C# in QM2.

C# code:
// script "Time in a country.cs"

//print.clear();
//foreach (var v in TimeZoneInfo.GetSystemTimeZones()) {
// print.it(v, v.Id);
//}

//Use the above code to discover time zone id. Then use it in code below.

var tz = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
var t = TimeZoneInfo.ConvertTime(DateTime.Now, tz);
osdText.showText($"Time in '{tz.Id}' is {t.TimeOfDay.ToString(@"hh\:mm\:ss")}");

//Another way - use a web service, eg worldtimeapi.org.


Forum Jump:


Users browsing this thread: 1 Guest(s)