Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ConvertFrom-DwordDate([int32]$DwordValue) {
- #Ex. $DwordValue = 132055314
- #Convert to hex with 8 chars (16bit year + 8bit month + 8bit day)
- $hex = $DwordValue.ToString('X8')
- #Ex. $hex = 0x07df0112 = 0x07df(year) 0x01 (month) 0x12 (day)
- #Convert to date string
- $datestring = '{0:D4}\{1:D2}\{2:D2}' -f [convert]::ToUInt32($hex.Substring(0,4),16), [convert]::ToUInt32($hex.Substring(4,2),16), [convert]::ToUInt32($hex.Substring(6,2),16)
- #Convert to datetime and output
- $datetime = [datetime]::ParseExact($datestring,'yyyy\\MM\\dd',$null)
- #Output
- $datetime
- }
- function ConvertTo-DwordDate([datetime]$Date = (Get-Date)) {
- #Convert to combined hex
- $combinedhex = '{0:X}{1:X2}{2:X2}' -f $Date.Year, $Date.Month, $Date.Day
- #Convert to decimal
- $decimal = [convert]::ToUInt32($combinedhex,16)
- #Ouput
- $decimal
- }
- $MyInvocation.MyCommand.Name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement