I have a problem with conversing a string variable in to a different data time variable.
My string is something like this:
[b]Sun Apr 12 14:37:28 2015[/b] – meaning – [b]abbreviated day, abbreviated month, day number, 24 hour, year[/b]
The main problem is with [u]culture[/u]. The string uses english names and my powershell uses polish names so when i try to format or parse the string i cannot read properly the abbreviated day and month 🙁
Second thing, important I think, I only need this string to put in date so I can manipulate the date, for example subtract 7 days and then again put in string and read the value 7 days before.
#Change locale for the current Thread to en-US
function Set-Culture([System.Globalization.CultureInfo] $culture)
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
This function changes the culture from this point on to en-US.
If you want to change it back later in the script, you run the function again using the polish culture.
Is this what you are looking for? If so, the date format string here assumes that the day will be in two digit form for days less than 10 (e.g. it expects 09 instead of just 9) . The date format string can be modified to expect single date values by changing dd to d.