March 22, 2018 at 5:51 pm #96815
I have been using the EnhancedHTML2 module to create some reports for my work and have ran into a problem/odity. Whenever I output a object to the "ConvertTo-EnhancedHTMLFragment" that has a date field it amends the date format from my locale which is UK to US. The best example I can give is if run the following on my own or any other pc's in my enterprise then I get the correct date format being output under the "timecreated" field i.e dd/MM/yyyy
Get-WinEvent application | ConvertTo-Html -Fragment | Out-File C:\temp\test.html
However when I run the following
Get-WinEvent application | ConvertTo-EnhancedHTMLFragment | Out-File C:\temp\test.html
The "timecreated" field is now displayed is US format i.e. MM/dd/yyyy
I can solve the display issue by simply converting the output to a string with the correct format but then I can't sort that table by date.
Really hoping somebody has a clue as to why this would happen as I have tried everything I can think of of nothing seems to give me a clue why the function would convert the date in this way.
March 22, 2018 at 5:58 pm #96824
However, do check the raw HTML in Notepad or something, and let me know what you see.
March 22, 2018 at 8:20 pm #96842
Hi Don, thank you for replying so quickly. I did as you suggested and looked at the raw html via notepad but found the date format was sill in US rather than UK format. Example below from one of the events when the ConvertTo-EnhancedHTMLFragment function was used
as opposed to the UK format when ConvertTo-HTML -frgamnent is used
checking get-culture returns
2057 en-GB English (United Kingdom)
could this be related to the UICulture?
March 22, 2018 at 8:29 pm #96843
That's the only thing I can think of. The code is at https://github.com/PowerShellOrg/EnhancedHTML2/blob/master/EnhancedHTML2.psd1; it may be that I'm processing things as strings and not as DateTime objects explicitly.
You must be logged in to reply to this topic.