Convertto-EnhancedHTMLFragment alters date format to US

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.

It’s not the ConvertTo-HTMLFragment command per se; it’s just using ConvertTo-HTML -Fragment under the hood. If you look at the raw HTML, I suspect you’ll see the date format you wanted. The problem is probably being caused by the dynamic table JavaScript library, which isn’t something I can address.

However, do check the raw HTML in Notepad or something, and let me know what you see.

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

03/22/2018 15:03:38

as opposed to the UK format when ConvertTo-HTML -frgamnent is used

22/03/2018 15:03:38

checking get-culture returns
2057 en-GB English (United Kingdom)

could this be related to the UICulture?

That’s the only thing I can think of. The code is at; it may be that I’m processing things as strings and not as DateTime objects explicitly.