Converting Object Types

by Aug 26, 2010

Once you know the name of an object type, you can use that type for conversion. The next line converts a string into a date-time type:

[DateTime] '4.5.2010'

You should note that conversion uses the culture-neutral date format which happens to be the U.S. format. If you need to use your local date format, you should use the Parse() method found inside the DateTime type:

[DateTime]::Parse('4.5.2010')

Twitter This Tip! ReTweet this Tip!