Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-TimeDetails {
- $format = 'yyyy.MM.dd HH:mm:ss'
- $now = Get-Date
- $tz = [System.TimeZoneInfo]::Local
- #Extending the DateTime object with further Properties
- Add-Member -InputObject $now -MemberType NoteProperty -Name UTCTime -Value $now.ToUniversalTime().ToString($format)
- Add-Member -InputObject $now -MemberType NoteProperty -Name LocalTime -Value $now.ToLocalTime().ToString($format)
- Add-Member -InputObject $now -MemberType NoteProperty -Name ZoneID -Value $([Regex]::Replace($tz.StandardName, '([A-Z])\w+\s*', '$1'))
- Add-Member -InputObject $now -MemberType NoteProperty -Name ZoneIDShort -Value $tz.StandardName
- $now.PSTypeNames.Insert(0, 'My.Custom.DateTime')
- $now
- }
- Update-FormatData .\Get-TimeDetails.format.ps1xml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement