Export (0) Print
Expand All
Expand Minimize

Converting VBScript's TimeValue Function


Windows PowerShell


Definition: Returns a Variant of subtype Date containing the time.

TimeValue

OK, so you have a string value (say, 1:45 AM) and you’d like to convert that to a date-time value, is that right? No problem; Windows PowerShell can do that for you. In this command we not only assign the string 1:45 AM to the variable $a, but we also explicitly give $a a datetime data type:


$a = [datetime] "1:45 AM"

When you run this command (assuming it was run on 9/21/2006) and then echo back the value of $a you should get the following:


Thursday, September 21, 2006 1:45:00 AM


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft