Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Converting VBScript's Time Function


Windows PowerShell


Definition: Returns a Variant of subtype Date indicating the current system time.

Time

OK, give us a hard one. What’s that? You’d like to store just the current time - and only the current time - in a variable? Fortunately, that’s not very hard; for example, one way we can do that is to call the Get-Date Cmdlet, then use the -displayhint parameter to assign just the current time to a variable. Sort of like this command, in which we store the current time to the variable $a:


$a = get-date -displayhint time

When you run this command and then echo back the value of $a you should get the following (assuming you run it at 11:22:37 AM):


11:22:37 AM


Return to the VBScript to Windows PowerShell home page

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.