Change Time format Powershell Azure

84 views Asked by At

I have a few Servers run in Microsoft Azure. I always had the timeformat dd/mm/yyyy but after this weekends update it changed for all of them to mm/dd/yyyy. For some reason im having a hard time fixing this small isue.

I need to change it because i run a application on the Server which does stuff with the time and it will also be printed out wrong. I tried to change it via the Date and time settings and this changes all when im on the server, but the application still shows the wrong format.

So I had a similar problem with the timezone, nothing i did on the Server itself did change anything i had to go via Windows Admin Center(in the Azure platform) and change it there with powershell, that did the job.

Now if if i do a get-culture it shows the wrong one(in windows admin center) even though its shown correct local on the server.

So now the question how can I change the time format for the entire Server permanent on every User in powershell, I dont need this other timeformat at all its not used in my Country.

1

There are 1 answers

0
Jahnavi On

Thanks @lit for pointing in the right direction. Set-Culture is used to set the user culture for the current account. Use below PowerShell script to achieve your requirement.

$changeto = 'en-US'  
[CultureInfo]::CurrentCulture = $changeto
[CultureInfo]::CurrentUICulture = $changeto
Set-Culture -CultureInfo $changeto | Out-Null
[DateTime]::Now.ToString('dd/MM/yyyy') 

Output:

enter image description here

Alternatively, you can also use az mysql server configuration set CLI command to change the date and time format of a server permanently.