Forum Discussion
Convert a text string to a correct date time format
- Jan 31, 2022sorry, I left the " | Get-Member " to show you that the type returned is a Date type. remove that to integrate into your own script
thank you for your reply, but it does not help me at the moment because all it gives me back is the following:
PS C:\WINDOWS\system32> [datetime](get-date('2020-08-06T06:03:19Z')) | get-member -MemberType Properties
TypeName: System.DateTime
Name MemberType Definition
---- ---------- ----------
Date Property datetime Date {get;}
Day Property int Day {get;}
DayOfWeek Property System.DayOfWeek DayOfWeek {get;}
DayOfYear Property int DayOfYear {get;}
Hour Property int Hour {get;}
Kind Property System.DateTimeKind Kind {get;}
Millisecond Property int Millisecond {get;}
Minute Property int Minute {get;}
Month Property int Month {get;}
Second Property int Second {get;}
Ticks Property long Ticks {get;}
TimeOfDay Property timespan TimeOfDay {get;}
Year Property int Year {get;}
DateTime ScriptProperty System.Object DateTime {get=if ((& { Set-StrictMode -Ver...
What I needed was a correct format as described. I solved it my way by cutting the last characters with this:
$CreatedDate.Remove(10,10)
it´s not smart but for now it will be enough for me 😉