Advertisement
Szeca

Untitled

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