- <#
- .SYNOPSIS
- This script converts time to different time zones.
- .DESCRIPTION
- This script re-implements an MSDN sample using PowerShell
- .NOTES
- File Name : Get-Time.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/08/get-time.html
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.timezoneinfo.findsystemtimezonebyid.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-Time.ps1
- Time in GMT Daylight Time zone: 8/29/2010 11:40:50 AM
- UTC Time: 8/29/2010 10:40:50 AM
- Time in Tokyo Daylight Time zone: 8/29/2010 07:40:50 PM
- UTC Time: 8/29/2010 10:40:50 AM
- #>
- # Get local time
- $thisTime = [system.DateTime]::Now
- if ([System.TimeZoneInfo]::Local.IsDaylightSavingTime($thisTime)) {
- $tzn = [System.TimeZoneInfo]::Local.DaylightName }
- else {
- $tzn = [System.TimeZoneInfo]::Local.StandardName
- }
- # Display local Time
- "Time in {0} zone: {1}" -f $tzn, $thisTime
- " UTC Time: {0}" -f [system.TimeZoneInfo]::ConvertTimeToUtc($thisTime, [TimeZoneInfo]::Local)
- # Get Tokyo Standard Time zone
- $tst = [system.TimeZoneInfo]::FindSystemTimeZoneById("Tokyo Standard Time")
- $tstTime = [system.TimeZoneInfo]::ConvertTime($thisTime, [TimeZoneInfo]::local, $tst)
- $tstzn = if ( [System.TimeZoneInfo]::Local.IsDaylightSavingTime($tstTime)) {
- $tst.DaylightName} else {$tst.StandardName}
- # Display Tokyo Time Zone
- "Time in {0} zone: {1}" -f $tstzn,$tstTime
- " UTC Time: {0}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($tstTime, $tst)
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label ConvertTimeToUtc. Show all posts
Showing posts with label ConvertTimeToUtc. Show all posts
Sunday, 29 August 2010
Get-Time.ps1
Subscribe to:
Posts (Atom)