Open SCH48 opened 4 years ago
$DateLocalTime = (get-date).AddDays(-1) Get-ZabbixHistory -TimeFrom $DateLocalTime -Items 30517
Error
Check convert DateTime
$DateLocalTimeToUnixTime = Datetime2Unix $DateLocalTime $DateTimeFromUnixTime = UnixTime2LocalTime $DateLocalTimeToUnixTime write-host $DateLocalTime "->" $DateLocalTimeToUnixTime "->" $DateTimeFromUnixTime
Change Function Datetime2Unix in power-zabbix.psm1
# Original @rrg92 # return $Datetime.toUniversalTime().Subtract([datetime]'1970-01-01').totalSeconds; # Change @SCH48 return ([DateTimeOffset]$Datetime).ToUnixTimeSeconds()
Get-ZabbixHistory is work!
Convert time does not match, but only hours
Change Function UnixTime2LocalTime in power-zabbix.psm1
# Original @rrg92 # return ([datetime]'1970-01-01').toUniversalTime().addSeconds($unixts).toLocalTime(); # Change @SCH48 return [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($unixts))
Checking
$DateLocalTime = (get-date).AddDays(-1) $DateLocalTimeToUnixTime = Datetime2Unix $DateLocalTime $DateTimeFromUnixTime = UnixTime2LocalTime $DateLocalTimeToUnixTime write-host $DateLocalTime "->" $DateLocalTimeToUnixTime "->" $DateTimeFromUnixTime Get-ZabbixHistory -TimeFrom $DateLocalTime -Items 30517
Now = 04.06.2020 12:40, AddDays(-1) = 03.06.2020 12:40
Best regards, @SCH48
Hey @SCH48 , can you submit a PR with this modification? And your name will appear as a contributor :)
This is the first time for me, but I will try if possible :-)
Hi! Trying to take a history by date..
Error
Check convert DateTime
Change Function Datetime2Unix in power-zabbix.psm1
Get-ZabbixHistory is work!
Convert time does not match, but only hours
Change Function UnixTime2LocalTime in power-zabbix.psm1
Checking
Now = 04.06.2020 12:40, AddDays(-1) = 03.06.2020 12:40
Best regards, @SCH48