Is there anyway to display system timezone using powershell GET-Timezone -ListAvailble. My requirements is to display this in a dropdownlist in an ASP page. Using .net com is not an option for me now, and even SQL server sys.time_zone_info.
Asked
Active
Viewed 838 times
0
-
3Please read about [how to ask a good question](http://stackoverflow.com/help/how-to-ask). – mklement0 Dec 11 '18 at 03:46
-
Possible duplicate of [Powershell Display current time with time zone](https://stackoverflow.com/questions/11035905/powershell-display-current-time-with-time-zone) – user692942 Dec 11 '18 at 09:10
-
Possible duplicate of [Dealing with timezones in vbscript](https://stackoverflow.com/a/37592262/692942) – user692942 Dec 11 '18 at 09:12
3 Answers
1
Gets the current time zone or a list of available time zones.
If you run it without parameters it gives the current timezone on the host computer.
Example output:
Id : GMT Standard Time
DisplayName : (UTC+00:00) Dublin, Edinburgh, Lisbon, London
StandardName : GMT Standard Time
DaylightName : GMT Daylight Time
BaseUtcOffset : 00:00:00
SupportsDaylightSavingTime : True

gvee
- 16,732
- 35
- 50
-
-
thanks for the answer, but I also want to know how to call this from ASP Classic and display this in a dropdownlist, my knowledge in ASP classic is not that good. – Linc Abela Dec 19 '18 at 02:59
1
You could use Shell.Exec to call the powershell command and read from the standard output.
The powershell part is from Lee_Dailey's answer
<%
Set objShell = server.CreateObject("WScript.Shell")
Set objExec = objShell.Exec("cmd /c powershell [System.TimeZoneInfo]::GetSystemTimeZones().DisplayName")
Set objStdOut = objExec.StdOut
Response.write "<select name=""Timezones"">"
While Not objStdOut.AtEndOfStream
Response.write "<option>" & objStdOut.ReadLine & "</option>"
Wend
Response.write "</select>"
%>

Flakes
- 2,422
- 8
- 28
- 32
0
if all you want is the offset/name for each timezone known to the current system, this will give that list ...
[System.TimeZoneInfo]::GetSystemTimeZones().DisplayName
as much as some may object, that is powershell. [grin]

Lee_Dailey
- 7,292
- 2
- 22
- 26
-
1
-
1you said you wanted powershell code to get the list. this gets that list with powershell code ... [*grin*] store the list in a $Var and use that to fill the ASP list. – Lee_Dailey Dec 11 '18 at 20:44
-
1My point is, getting the list in powershell has been covered before. Plus, it’s only part of the answer in which case it’s a duplicate. – user692942 Dec 11 '18 at 21:41
-
1@Lankymart - ah! i completely misunderstood your question. i thot it was about powershell, not about how to code in ASP. i think you may have made an error in using the powershell tag for this. [*grin*] – Lee_Dailey Dec 11 '18 at 21:56
-
1@Lankymart - ah! the powershell tag led me to misunderstand your intent. whoever added that may have made an error. – Lee_Dailey Dec 11 '18 at 22:26
-
thanks for the answer, but I also want to know how to use this from ASP Classic and display this in a dropdownlist, im not doing this in a standalone powershell script. – Linc Abela Dec 19 '18 at 02:59