This topic contains 3 replies, has 2 voices, and was last updated by
March 22, 2018 at 5:51 pm #96815ParticipantPoints: 1Rank: Member
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 #96824KeymasterPoints: 1,811Rank: Community Hero
However, do check the raw HTML in Notepad or something, and let me know what you see.
March 22, 2018 at 8:20 pm #96842ParticipantPoints: 1Rank: Member
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 #96843KeymasterPoints: 1,811Rank: Community Hero
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.
The topic ‘Convertto-EnhancedHTMLFragment alters date format to US’ is closed to new replies.