Converting Object Types

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!


Posted Aug 26 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.